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

algo_040.md (450B)


      1 # algo_040
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to enqueue an element into a linear queue using linked representation.
      6 
      7 ## Algorithm
      8 ```
      9 procedure enqueue(rear, front, val)
     10 begin
     11     ptr ← getNode();
     12     info(ptr) ← val;
     13     next(ptr) ← NULL;
     14     if (front = NULL and rear = NULL) then
     15         front ← ptr;
     16         rear ← ptr;
     17     else
     18         next(rear) ← ptr;
     19         rear ← ptr;
     20     endif
     21     return(rear);
     22 end procedure
     23 ```