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

algo_043.md (466B)


      1 # algo_043
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to dequeue an element from a circular queue using linked representation.
      6 
      7 ## Algorithm
      8 ```
      9 procedure dequeue(cq)
     10 begin
     11     if (cq = NULL) then
     12         write("Deletion not possible");
     13     else if (next(cq) = cq) then
     14         ptr ← cq;
     15         cq ← NULL;
     16         delete(ptr);
     17     else
     18         ptr ← next(cq);
     19         next(cq) ← next(ptr);
     20         delete(ptr);
     21     endif
     22     return(cq);
     23 end procedure
     24 ```