Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to move the pointer forward in a singly linked list.
DSA C
current = current[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.next' instead of '->next' in pointer access.
Using 'prev' pointer which does not exist in singly linked list.
✗ Incorrect
In a singly linked list, to move forward, you use the 'next' pointer with '->' operator.
2fill in blank
mediumComplete the code to move the pointer backward in a doubly linked list.
DSA C
current = current[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.prev' instead of '->prev' in pointer access.
Using 'next' pointer to move backward.
✗ Incorrect
In a doubly linked list, to move backward, you use the 'prev' pointer with '->' operator.
3fill in blank
hardFix the error in the traversal code to move forward in a singly linked list.
DSA C
while (current != NULL) { printf("%d -> ", current->data); current = current[1]; } printf("NULL\n");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' pointer which does not exist in singly linked list.
Using '.' operator instead of '->' for pointer access.
✗ Incorrect
To move forward in a singly linked list, use 'current = current->next;'.
4fill in blank
hardFill both blanks to traverse backward and print data in a doubly linked list.
DSA C
while (current != NULL) { printf("%d -> ", current->data); current = current[1]; } printf("NULL\n"); // To move backward: current = tail; while (current != NULL) { printf("%d -> ", current->data); current = current[2]; } printf("NULL\n");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.' operator instead of '->'.
Mixing up next and prev pointers.
✗ Incorrect
To move forward, use '->next'. To move backward, use '->prev' in doubly linked list.
5fill in blank
hardFill all three blanks to create a function that prints a doubly linked list forward and backward.
DSA C
void printList(struct Node* head, struct Node* tail) {
struct Node* current = head;
while (current != NULL) {
printf("%d -> ", current[1]);
current = current[2];
}
printf("NULL\n");
current = tail;
while (current != NULL) {
printf("%d -> ", current[3]);
current = current->prev;
}
printf("NULL\n");
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.' instead of '->' for pointer access.
Using wrong pointer to move forward or backward.
✗ Incorrect
To print data, use '->data'. To move forward, use '->next'. The last print also uses '->data'.
