Concept Flow - Binary Search vs Linear Search Real Cost Difference
Start at index 0
Check element == target?
No→Move to next index
Index < array size?
No→Not found
Found element
Repeat check
Start with low=0, high=n-1
Calculate mid = (low+high)/2
Check element at mid == target?
Found
high = mid-1
low <= high?
No→Not found
Linear search checks each element one by one until it finds the target or ends. Binary search repeatedly splits the sorted array in half to find the target faster.