bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_2 / algorithms / algo_017.md

algo_017.md (472B)


      1 # algo_017
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to merge two sorted circular linked list.
      6 
      7 ## Algorithm
      8 ```
      9 procedure merge(cl1, cl2)
     10 begin
     11     if(cl1 = NULL && cl2 = NULL) 
     12         return(cl1);
     13     else if(cl1 ≠ NULL && cl2 = NULL) 
     14         return(cl1);
     15     else if(cl1 = NULL && cl2 ≠ NULL) 
     16         return(cl2);
     17     else 
     18         ptr ← next(cl2);
     19         next(cl2) ← next(cl1);
     20         next(cl1) ← ptr;
     21         return(cl2);
     22     endif
     23 end procedure
     24 ```