AlgoScope

Find Middle

Slow moves one, fast moves two. When fast runs out, slow is halfway.

Linked list algorithms, algorithm, beginner
Slow is at 4. Fast is at 7.1234567headslowfast
Slow is at 4. Fast is at 7.1234567headslowfast

Fast and Slow Pointers: Find the middle of seven

Decision, step 4 of 5

Step 3: slow moves to 4, fast jumps two to 7. Fast has nowhere left to go.

Cost

Best
O(n)
Average
O(n)
Worst
O(n)
Space
O(1)

Leads to

Topics that need this one first.

Taught by the same lesson

Fast and Slow Pointers covers these too, in the same run.