Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to move the pointer to the head of the list.
DSA C
struct Node* current = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL instead of head causes no traversal.
Using tail pointer will not start from the beginning.
✗ Incorrect
We start from the head of the linked list to delete a node at a specific position.
2fill in blank
mediumComplete the code to move the pointer to the node before the one to delete.
DSA C
for (int i = 0; i < position - 1; i++) { current = current->[1]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' in singly linked list causes errors.
Using 'child' or 'parent' are invalid pointers here.
✗ Incorrect
We move to the next node to reach the node before the one to delete.
3fill in blank
hardFix the error in updating the link to skip the deleted node.
DSA C
current->[1] = current->next->next; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' causes compilation errors.
Using 'child' or 'parent' are invalid in this context.
✗ Incorrect
We update current's next pointer to skip the node to delete.
4fill in blank
hardFill both blanks to correctly free the deleted node and update the list.
DSA C
struct Node* temp = current->[1]; current->[2] = temp->next; free(temp);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' causes errors in singly linked list.
Not freeing the node causes memory leaks.
✗ Incorrect
We store the node to delete in temp, update current's next to skip it, then free temp.
5fill in blank
hardFill all three blanks to handle deleting the head node correctly.
DSA C
if (position == 0) { struct Node* temp = [1]; [2] = [3]->next; free(temp); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not updating head causes list corruption.
Freeing before updating head causes access errors.
✗ Incorrect
To delete the head node, store it in temp, move head to next node, then free temp.
