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

algo_005.md (467B)


      1 # algo_005
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to insert a node at the end of the list.
      6 
      7 ## Algorithm
      8 ```
      9 procedure insertEnd(head)
     10 begin
     11     nptr ← getnode();
     12     write("Enter info: ");
     13     read(val);
     14     info(nptr) ← val;
     15     if(head = NULL)
     16         head ← nptr;
     17     else
     18         ptr ← head;
     19         while(next(ptr) ≠ NULL)
     20             ptr ← next(ptr);
     21         end while
     22         next(ptr) ← nptr;
     23     endif
     24     return(head);
     25 end procedure
     26 ```