Instructions: This assignment involves using recursive method. Write a program that reverses a LinkedList. Save the code

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Instructions: This assignment involves using recursive method. Write a program that reverses a LinkedList. Save the code

Post by answerhappygod »

Instructions:
This assignment involves using recursive method. Write a program
that reverses a LinkedList.
Save the code in jGRASP, then save it in c:\myjava and run
it.
/*******************
Name:
Date:
Notes:
*******************/
// Java program for reversing the linked list

class MyLinkedList {

static Node head;

static class Node {

int data;
Node next;

Node(int d) {
data = d;
next = null;
}
}

/* Function to reverse the linked list */
Node reverse(Node node) {
add content
node = prev;
return node;
}

// prints content of double linked list
void printList(Node node) {
while (node != null) {
System.out.print(node.data + " ");
node = node.next;
}
}

public static void main(String[] args) {
MyLinkedList list = new MyLinkedList();
add content }
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply