- #1
ainster31
- 158
- 1
Homework Statement
Homework Equations
The Attempt at a Solution
I don't understand how when p1 hits the end of the linked list, p2 will be at the midpoint.
This is how I am imagining it if n=3. Each step below represents an iteration.
1. a1 (p1, p2)->a2->a3->b1->b2->b3
2. a1->a2 (p2)->a3 (p1)->b1->b2->b3
3. a1->a2->a3 (p2)->b1->b2 (p1)->b3
4. Index out of bounds error because p2 now points to a node after b3.