Java Practice-It || 16.13 linkedNodes13 || ListNodes, LinkedLists

preview_player
Показать описание
Question:
Write the code necessary to convert the following sequence of ListNode objects:

list [5] [4] [3] /
Into this sequence of ListNode objects:

list [4] [5] [3] /
Assume that you are using ListNode class as defined in the textbook:

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) { ... }
}

Problems:
Рекомендации по теме
Комментарии
Автор

Hi, yes it was just store five It only stores the head of the list. The object at the front is a list node so it doesn't store the whole list just the single front node

ComputerEngineeringCPE
Автор

On the first line, when you write ListNode temp = list; does it just store 5? and why it won't store the whole LinkedList(5, 4, 3, /)?

BamdadGoshtasbi