Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to update the head pointer after deleting the first node.
DSA C#
head = head[1];Attempts:
3 left
💡 Hint
Common Mistakes
Using '.prev' instead of '.next' to update head.
Skipping nodes by using '.next.next'.
✗ Incorrect
After deleting the first node, the head should point to the next node in the list.
2fill in blank
mediumComplete the code to set the previous pointer of the new head to null.
DSA C#
if (head != null) head[1] = null;
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 'next' pointer to null instead of 'prev'.
Not checking if head is null before accessing pointers.
✗ Incorrect
The previous pointer of the new head should be null because it is the first node.
3fill in blank
hardFix the error in the code that deletes the first node of the doubly linked list.
DSA C#
if (head != null) { Node temp = head; head = head[1]; if (head != null) head.prev = null; temp = null; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.prev' instead of '.next' to update head.
Not setting the new head's prev pointer to null.
✗ Incorrect
To delete the first node, head should move to head.next, not head.prev.
4fill in blank
hardFill both blanks to correctly delete the first node and update pointers.
DSA C#
if (head != null) { Node temp = head; head = head[1]; if (head != null) head[2] = null; temp = null; }
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping '.next' and '.prev' in the blanks.
Not setting the new head's prev pointer to null.
✗ Incorrect
First, move head to head.next, then set head.prev to null to update the list correctly.
5fill in blank
hardFill all three blanks to delete the first node and ensure the list is updated properly.
DSA C#
if (head != null) { Node temp = head; head = head[1]; if (head != null) head[2] = null; temp[3] = null; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect pointer names or missing null checks.
Not clearing temp.next which may cause memory leaks.
✗ Incorrect
Move head to head.next, set head.prev to null, and clear temp.next to help garbage collection.
