Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the slow pointer to the head of the list.
DSA C
struct Node* slow = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing slow to NULL will cause no traversal.
Using fast instead of head mixes pointer roles.
✗ Incorrect
The slow pointer should start at the head of the linked list to begin traversal.
2fill in blank
mediumComplete the code to move the fast pointer two steps ahead safely.
DSA C
fast = fast->next->[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' is invalid in singly linked lists.
Accessing 'data' instead of 'next' causes errors.
✗ Incorrect
To move two steps ahead, access next of next node using fast->next->next.
3fill in blank
hardFix the error in the loop condition to check if fast and fast->next are not NULL.
DSA C
while (fast != NULL && fast->[1] != NULL) {
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking 'prev' causes compilation errors in singly linked lists.
Checking 'data' is meaningless for pointer safety.
✗ Incorrect
We must check fast->next to ensure the fast pointer can move two steps safely.
4fill in blank
hardFill both blanks to update slow and fast pointers correctly inside the loop.
DSA C
slow = slow->[1]; fast = fast->[2]->next;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' in singly linked lists causes errors.
Using 'data' instead of 'next' breaks pointer logic.
✗ Incorrect
Both slow and fast pointers move forward using the 'next' pointer.
5fill in blank
hardFill all three blanks to return true if the list is circular, else false.
DSA C
if (slow == [1]) { return [2]; } else { return [3]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning false when pointers meet is wrong.
Comparing slow to head instead of fast misses the cycle.
✗ Incorrect
If slow meets fast, the list is circular (return true), else return false.
