bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

algo_022.md (635B)


      1 # algo_022
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to insert a node at the end of a double linked list.
      6 
      7 ## Algorithm
      8 ```
      9 procedure insert_end(dl, val)
     10 begin
     11     // node creation and initialization
     12     nptr ← getNode();
     13     info(nptr) ← val;
     14     prev(nptr) ← NULL;
     15     next(nptr) ← NULL;
     16     // List is empty
     17     if(dl = NULL)
     18         dl ← nptr;
     19     else // List is not empty
     20         p ← dl;
     21         while(next(p) ≠ NULL) // move 'p' to the last node.
     22             p ← next(p);
     23         end while
     24         prev(nptr) ← p; // insertion at the end
     25         next(p) ← nptr;
     26     endif
     27     return(dl);
     28 end procedure
     29 ```
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror