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

algo_039.md (548B)


      1 # algo_039
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to dequeue (circular queue)
      6 
      7 ## Algorithm
      8 ```
      9 Procedure dequeue(Q[], front, rear, Qsize)
     10 begin
     11     if (front = -1) then
     12         write("Queue empty.")
     13     else
     14         val ← Q[front]                   
     15         write("Deleted element: ", val)
     16 
     17         // CORRECTED SECTION:
     18         if (front = rear) then           
     19             front ← -1
     20             rear ← -1
     21         else                             
     22             front ← (front + 1) % Qsize
     23         endif
     24     endif
     25 end procedure
     26 
     27 ```