bsc

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

algo_006.md (563B)


      1 # algo_006
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to delete the last node of the list.
      6 
      7 ## Algorithm
      8 ```
      9 procedure deletelastnode(head)
     10 begin
     11     if(head = NULL)
     12         write("List is empty, deletion not possible.");
     13     else if(next(head) = NULL) 
     14         ptr ← head;
     15         head ← next(ptr);
     16         delete(ptr);
     17     else 
     18         ptr ← head;
     19         while(next(ptr) ≠ NULL)
     20             prev ← ptr;
     21             ptr ← next(ptr);
     22         end while
     23         delete(ptr);
     24         next(prev) ← NULL;
     25     endif
     26     return(head);
     27 end procedure
     28 ```
© 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