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_018.md

algo_018.md (453B)


      1 # algo_018
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to delete the first node of the circular linked list.
      6 
      7 ## Algorithm
      8 ```
      9 procedure delFirst(cl)
     10 begin
     11     if(cl = NULL)
     12         write("Nothing to delete.");
     13     else
     14         ptr ← next(cl);
     15         if(ptr = cl)
     16             delete(ptr);
     17             cl ← NULL;
     18         else
     19             next(cl) ← next(ptr);
     20             delete(ptr);
     21         endif
     22         return(cl);
     23     endif
     24 end procedure
     25 ```