algo_025.md (587B)
1 # algo_025 2 3 ### Problem Statement 4 5 > Write an algorithm to delete the last node from a double linked list. 6 7 ## Algorithm 8 ``` 9 Procedure delete_lastNode(dl) 10 begin 11 if (dl = NULL) then 12 write("List is empty, deletion not possible."); 13 else 14 ptr ← dl; 15 if (next(ptr) = NULL) then 16 dl ← NULL; 17 delete(ptr); 18 else 19 while (next(ptr) ≠ NULL) do 20 ptr ← next(ptr); 21 endwhile 22 next(prev(ptr)) ← NULL; 23 delete(ptr); 24 endif 25 endif 26 return(dl); 27 end procedure 28 ```