Question
Hello Q: Print a singly linked list in reverse order by using recursive algorithm please explain the code : class SingleyLinkedList { Node head; class
Hello
Q: Print a singly linked list in reverse order by using recursive algorithm
please explain the code :
class SingleyLinkedList
class Node
rev data; Node next;
Node(rev d) {
data = d; next = null; } } void Reverse(Node
public void add(rev data) { Node new_node = new Node(data); new_node.next = head; head = new_node; }
public void print() { Node current = head; if (head == null) { System.out.println("List is empty"); } else { do {
System.out.print(" " + current.data); current = current.next; } while (current != null); System.out.println(); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started