Guest User

Untitled

a guest
Jan 23rd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. LinkedList reverseList(LinkedList n){
  2.  
  3. /* all these are null values */
  4. Node current;
  5. Node prev;
  6. Node prev_link;
  7.  
  8.  
  9. current = n;
  10. while(current.next != null){
  11. prev = current;
  12. prev.next = prev_link;
  13. prev_link = current;
  14. current = current.next;
  15. if(current.next == null){
  16. current.next = prev;
  17. }
  18. }
  19.  
  20. return current;
  21. }
Add Comment
Please, Sign In to add comment