logo CodeStepByStep logo

nodes14

Language/Type: Java ListNodes LinkedLists
Related Links:

Write the code necessary to convert the following sequence of ListNode objects:

list -> [5] -> [4] -> [3] /

Into these sequences of ListNode objects:

list -> [3] -> [5] /
list2 -> [4] -> [3] -> [5] /

Assume that you are using ListNode class as defined in lecture and section:

public class ListNode {
    public int data;       // data stored in this node
    public ListNode next;  // a link to the next node in the list

    public ListNode() { ... }
    public ListNode(int data) { ... }
    public ListNode(int data, ListNode next) { ... }
}
Bare code: Write a fragment of Java code as described, without any class or function/method heading around your code.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.