Complete the code to update the head pointer when deleting the first node.
head = [1];When deleting the first node, the head should point to the next node.
Complete the code to set the previous pointer of the new head to null after deletion.
if (head != null) { head.[1] = null; }
After deleting the first node, the new head's previous pointer should be null.
Fix the error in the code that deletes the first node of the doubly linked list.
public void deleteFromBeginning() {
if (head == null) {
return;
}
head = [1];
if (head != null) {
head.prev = null;
}
}The head should be updated to head.next to remove the first node.
Fill both blanks to complete the method that deletes the first node and returns its data.
public int deleteFromBeginning() {
if (head == null) {
return -1;
}
int data = head.data;
head = [1];
if (head != null) {
head.[2] = null;
}
return data;
}Update head to head.next and set head.prev to null after deletion.
Fill all three blanks to complete the method that deletes the first node and updates the list correctly.
public int deleteFromBeginning() {
if (head == null) {
return -1;
}
int data = head.[1];
head = [2];
if (head != null) {
head.[3] = null;
}
return data;
}Access data from head.data, move head to head.next, and set head.prev to null.
