Consider a linked list of integers defined by the following class definition. ?
Consider a linked list of integers defined by the following class definition. class Node { int data; Node next; } Write a recursive method that accepts the head of the list as a parameter and displays the values of the list in forward order.
Public Comments
- In Java: public void recursion(Node head) { if(head != null) { System.out.println(head.data) recursion(head.next()) } }
- In C++: public void recursion(Node head) { if(head != null) { cout<<head.data recursion(head.next()) } } :):)
Powered by Yahoo! Answers