Question: 3 2 ) Which XXX is the correct code to add an item to the beginning of a linked list? addFirst ( list , newNode

32) Which XXX is the correct code to add an item to the beginning of a linked list?
addFirst (list, newNode){
if (list.head == null){
list.head = newNode
list.tail = newNode
}
else {
XXX
}
}
A) newNode.next = list.head
list.head = newNode
C) list.head.next = newNode
list.head = newNode
B) newNode.next = list.tail
list.tail = newNode
D) list.tail.next = newNode
list.tail = newNode

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!