Binary Search Visualization

Sort and search demonstration

Visual Demonstration

Algorithm Explanation

Binary Search Demonstration

This visualization demonstrates two key algorithms: first sorting the unsorted array (using bubble sort), then applying binary search to find a target value.

Binary Search Process

  1. 1 Sort the array (required for binary search)
  2. 2 Find the middle element of the array
  3. 3 Compare target with middle element
  4. 4 If target found, return position
  5. 5 If target < middle, search left half
  6. 6 If target > middle, search right half

Complexity Analysis

Sorting Time: O(n²) with bubble sort
Binary Search Time: O(log n)
Space Complexity: O(1)
Green = Sorted elements, Purple = Middle element, Red = Current search range