DSA-VerseLearn by watching code run
DashboardData StructuresAlgorithmsVisualizerCORECoding PlaygroundInterview QuestionsComplexity AnalyzerLearning NotesBookmarksLearning ProgressSettings
Instrumented JavaScript implementation · lines sync with the animation

Run to execute this JavaScript code for real (output appears here).

Reverse an Array

arrays
1
2
3
4
5
6
0
1
2
3
4
5
ComparingSwapping / movingCurrentSorted / finalFound / placed

Ready.

Reverses an array in place with two pointers: swap the outermost pair, move both pointers inward, and stop when they meet. Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.

1 / 17

Execution

Step

1 / 17

Line (JavaScript)

—

FUNCTION_CALL

Variables

arr[1, 2, 3, 4, 5, 6]
Call stackdepth 0

main (no active function frames)

Operation counters

No counted operations yet.

Memory (measurable)

Extra variablesleft, right
Auxiliary spaceO(1) — in place

Data structure state

[1, 2, 3, 4, 5, 6]