AlgoScope

Reverse Linked List

AlgorithmbeginnerLinked List Operations

Walk the list with three pointers and flip each arrow to face the other way.

Decision · step 2 of 11Singly Linked List: Reverse the list
5142currheadnext

Remember next (1), then flip 5's arrow to point back at null.

Open in the player →or start at step 2

What you will see

Three pointers march; every arrow detaches and reattaches pointing the other way.

How singly linked list works →

Cost

BestO(n)
AverageO(n)
WorstO(n)
SpaceO(1)

Recursive variant uses O(n) stack.

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.

Screen readers: Each node announces its value and what it points to; each step announces the pointer change ("node 3 now points to node 5").

Reduced motion: Pointer arrows redraw in place with a brief emphasis instead of animating the detach and reattach.

Before this

Variants

  • Iterative Three-pointer walk.
  • Recursive Reverse the rest

Leads to

Topics that need this one first.

Taught by the same lesson

Singly Linked List covers these too, in the same run.