Advertisement
Guest User

print

a guest
Sep 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.52 KB | None | 0 0
  1. /*
  2.   Print elements of a linked list in reverse order
  3.   head pointer input could be NULL as well for empty list
  4.   Node is defined as
  5.   class Node {
  6.      int data;
  7.      Node next;
  8.   }
  9. */
  10.     // This is a "method-only" submission.
  11.     // You only need to complete this method.
  12.  
  13. void ReversePrint(Node head) {
  14.   // This is a "method-only" submission.
  15.   // You only need to complete this method.
  16.     if (head == null)
  17.         return;
  18.    
  19.     ReversePrint(head.next);
  20.     System.out.println(head.data);
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement