CZ
CalcyZone
computer-science Verified Precision Tool

Binary Search Calculator & Visualizer

Interactive step-by-step Binary Search visualizer with lower/upper range tracking and O(log n) elimination.

Interactive Algorithm Visualizer

Binary Search

Enter your custom input data → Run the real algorithm engine → Observe step transitions.

⚙️ Customize Algorithm Input Data

Step 1 of 1⚡ Algorithm Running
WHAT HAPPENED?

Search space [0..4]. Mid index 2 (22) vs target (22).

WHY?

Algorithm state rule requirement

WHAT CHANGED?

State pointers updated

11
[0]
12
[1]
22
[2]
25
[3]
64
[4]

Mathematical Formula

mid = floor((low + high) / 2); compare arr[mid] with target

Overview & Explanation

Binary Search searches a sorted array by repeatedly dividing the search interval in half.

How It Works

  • Compare target value to the middle element of the array.
  • If target equals mid element, search is complete.
  • If target < mid, eliminate upper half. If target > mid, eliminate lower half.

Practical Applications

  • Fast searching in sorted databases
  • Finding boundaries and lower bounds

Binary Search Step Derivation

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

1

Pass 1

Low=0, High=9, Mid=4 (Val 16)

= 23 > 16 -> Low=5
2

Pass 2

Low=5, High=9, Mid=7 (Val 56)

= 23 < 56 -> High=6
3

Pass 3

Low=5, High=6, Mid=5 (Val 23)

= Target found at Index 5!

Frequently Asked Questions

Does Binary Search require a sorted array?
Yes, Binary Search requires input elements to be sorted in ascending or descending order.