PLEASE ANSWER ASAP Give the codes according to the above illustration. Fill in the missing pieces.
Posted: Fri May 20, 2022 6:41 pm
PLEASE ANSWER ASAP
Give the codes according to the above illustration. Fill in the
missing pieces.
(Cont.) In Lab 8, consider the implementation of method swap(). Next, consider the case where the nodes to be swapped are NOT adjacent as shown below. Assume that both nodes I and J to be swapped exist in the linked list. To perform swapping correctly, we have to find the following nodes first in another methods. • A: the node before I. If I is the list head, then A=null; • B: the node after I. • X: the node before J. • Y: the node after J. If J is the list tail, then Y==null; Below is the graph that illustrates how to implement this method. head tail 1 2 7 A B Y Z Z head J 1 3 8 Α. 1 B Y Z
Give the codes according to the above illustration. Fill in the missing pieces. b__; • If (head==1) head= a___; • If (J.next==null) tail = • If (A!=null) A.next = _C___; • J.next = d; • Y.next = e; • I. Next = f. Hints: • Check method swap in the lab partial answer keys here: answer.LinkedList.java • Follow the instructions at the top of the program file. • Plug in your answers and see if your program output is the same as the expected. a [Choose ] B J None is a correct answer z b с [Choose ] A d [ Choose ] e [Choose ] 4 f [Choose 1
Give the codes according to the above illustration. Fill in the
missing pieces.
(Cont.) In Lab 8, consider the implementation of method swap(). Next, consider the case where the nodes to be swapped are NOT adjacent as shown below. Assume that both nodes I and J to be swapped exist in the linked list. To perform swapping correctly, we have to find the following nodes first in another methods. • A: the node before I. If I is the list head, then A=null; • B: the node after I. • X: the node before J. • Y: the node after J. If J is the list tail, then Y==null; Below is the graph that illustrates how to implement this method. head tail 1 2 7 A B Y Z Z head J 1 3 8 Α. 1 B Y Z
Give the codes according to the above illustration. Fill in the missing pieces. b__; • If (head==1) head= a___; • If (J.next==null) tail = • If (A!=null) A.next = _C___; • J.next = d; • Y.next = e; • I. Next = f. Hints: • Check method swap in the lab partial answer keys here: answer.LinkedList.java • Follow the instructions at the top of the program file. • Plug in your answers and see if your program output is the same as the expected. a [Choose ] B J None is a correct answer z b с [Choose ] A d [ Choose ] e [Choose ] 4 f [Choose 1