Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to move the pointer to the next node in the linked list.
DSA C
current = current[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot operator instead of arrow operator for pointer access.
Using 'next' without any operator.
✗ Incorrect
In C, to access the next node pointer from a pointer to a struct, use the arrow operator '->' followed by 'next'.
2fill in blank
mediumComplete the code to check if two pointers point to the same node.
DSA C
if (ptrA [1] ptrB) { // Intersection found }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator '=' instead of comparison '=='.
Using '!=' which checks for inequality.
✗ Incorrect
To check if two pointers point to the same node, use the equality operator '=='.
3fill in blank
hardFix the error in the loop condition to traverse the linked list until the pointer is NULL.
DSA C
while (current [1] NULL) { current = current->next; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' causes the loop to run only when current is NULL, which is incorrect.
Using '<' or '>' operators with pointers is invalid.
✗ Incorrect
To traverse until the pointer is NULL, the loop should continue while current is not equal to NULL, using '!='.
4fill in blank
hardFill both blanks to correctly advance pointers and handle switching lists when reaching the end.
DSA C
if (ptrA == NULL) { ptrA = [1]; } else { ptrA = ptrA[2]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Switching to the wrong list head.
Using incorrect pointer member like '->prev'.
✗ Incorrect
When ptrA reaches NULL, it should switch to headB. Otherwise, it moves to the next node using '->next'.
5fill in blank
hardFill all three blanks to complete the function that finds the intersection point of two linked lists.
DSA C
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
struct ListNode *ptrA = headA;
struct ListNode *ptrB = headB;
while (ptrA != ptrB) {
ptrA = (ptrA == NULL) ? [1] : ptrA[2];
ptrB = (ptrB == NULL) ? [3] : ptrB->next;
}
return ptrA;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up headA and headB when switching pointers.
Using incorrect pointer member like '->prev'.
✗ Incorrect
When ptrA is NULL, switch to headB; otherwise move to next node with '->next'. For ptrB, switch to headA if NULL, else move to next node.
