Search Algorithms

7 different search algorithms with automated execution and step-by-step visualization

Algorithm Reference

Linear Search

Sequentially checks each element until the target is found or the end is reached.

for i = 0 to n-1:
  if arr[i] == target:
    return i
return -1
Best: O(1) Avg: O(n) Worst: O(n)

Binary Search

Divides the search interval in half repeatedly. Requires sorted array.

while left <= right:
  mid = (left + right) / 2
  if arr[mid] == target: return mid
  if arr[mid] < target: left = mid + 1
  else: right = mid - 1
Best: O(1) Avg: O(log n) Worst: O(log n)