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).

Binary Search

searching
2
5
8
12
16
23
38
56
72
91
0
1
2
3
4
5
6
7
8
9
ComparingSwapping / movingCurrentSorted / finalFound / placed

Ready.

Searches a sorted array by repeatedly comparing the target with the middle element and discarding the half that cannot contain it. 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

target23
Call stackdepth 0

main (no active function frames)

Operation counters

No counted operations yet.

Memory (measurable)

Extra variableslow, high, mid
Auxiliary spaceO(1) — iterative

Data structure state

[2, 5, 8, 12, 16, 23, 38, 56, 72, 91]