Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start traversal from the head node.
DSA C
struct Node* current = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting traversal from tail instead of head.
Using NULL as starting point in circular list.
✗ Incorrect
Traversal of a circular linked list starts from the head node.
2fill in blank
mediumComplete the condition to stop traversal after one full cycle.
DSA C
do {
printf("%d -> ", current->data);
current = current->next;
} while (current != [1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL as stopping condition in circular list.
Stopping traversal too early or too late.
✗ Incorrect
Traversal stops when current reaches head again, completing the cycle.
3fill in blank
hardFix the error in the traversal loop to avoid infinite loop.
DSA C
struct Node* current = head;
do {
printf("%d -> ", current->data);
[1];
} while (current != head); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using current->prev causes backward traversal or errors.
Assigning current to head inside loop causes infinite loop.
✗ Incorrect
To move forward in the list, current must be updated to current->next.
4fill in blank
hardFill both blanks to create a function that prints all nodes in a circular linked list.
DSA C
void traverseCircularList(struct Node* [1]) { struct Node* current = [2]; if (current == NULL) return; do { printf("%d -> ", current->data); current = current->next; } while (current != [1]); printf("NULL\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail or other pointers instead of head.
Starting traversal from a NULL pointer.
✗ Incorrect
The function parameter and starting pointer should both be 'head' to traverse correctly.
5fill in blank
hardFill all three blanks to correctly insert a new node at the end of a circular linked list.
DSA C
void insertEnd(struct Node** [1], int data) { struct Node* newNode = malloc(sizeof(struct Node)); newNode->data = data; if (*[2] == NULL) { newNode->next = newNode; *[3] = newNode; } else { struct Node* temp = *[3]; while (temp->next != *[3]) { temp = temp->next; } temp->next = newNode; newNode->next = *[3]; } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing head and tail pointers.
Not updating the list pointer correctly.
✗ Incorrect
The function uses a pointer to head to insert at the end; all blanks should be 'head' for correct insertion.
