Bird
0
0
DSA Cprogramming~10 mins

Intersection Point of Two Linked Lists in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Anext
B->next
C->prev
D.next
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot operator instead of arrow operator for pointer access.
Using 'next' without any operator.
2fill in blank
medium

Complete 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'
A==
B!=
C=
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator '=' instead of comparison '=='.
Using '!=' which checks for inequality.
3fill in blank
hard

Fix 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'
A>
B==
C<
D!=
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.
4fill in blank
hard

Fill 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'
AheadB
BheadA
C->next
D->prev
Attempts:
3 left
💡 Hint
Common Mistakes
Switching to the wrong list head.
Using incorrect pointer member like '->prev'.
5fill in blank
hard

Fill 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'
AheadB
BheadA
C->next
D->prev
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up headA and headB when switching pointers.
Using incorrect pointer member like '->prev'.