Someone Please Explain D Correct Answer Piece Code Written Java Thanks Given Following Def Q37256858

can someone please explain to me why (d) is the correctanswer.

this piece of code is written in java.

thanks.

Given the following definition of ListNode constructor (similarto the one we have in our doubly-linked list example).

public ListNode (T v, ListNode<T> n) { this.value = v; this.next = n;}

Which statement inserts an item x right after the node pointedby “current” in the linked list?

bcurrent = new ListNode(x, current.next);ccurrent.next = new ListNode(x, current);dcurrent.next = new ListNode(x, current.next);enone of the above


Answer


current.next = new ListNode(x, current.next);Current state of linked listcurrent -> node1 -> node2 …=> new ListNode(x,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.