algo_017
Problem Statement
Problem Statement
Write an algorithm to merge two sorted circular linked list.
Algorithm
procedure merge(cl1, cl2)
begin
if(cl1 = NULL && cl2 = NULL)
return(cl1);
else if(cl1 ≠ NULL && cl2 = NULL)
return(cl1);
else if(cl1 = NULL && cl2 ≠ NULL)
return(cl2);
else
ptr ← next(cl2);
next(cl2) ← next(cl1);
next(cl1) ← ptr;
return(cl2);
endif
end procedure1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15