Concept Flow - Binary Search vs Linear Search Real Cost Difference
Start at index 0
Check element == target?
No→Move to next index
Reached end?
Yes→Not found
Found
Start with low=0, high=n-1
Calculate mid = (low+high)/2
Check element at mid == target?
Found
Repeat until low > high
Not found
Linear search checks each element one by one until it finds the target or ends. Binary search splits the search range in half each time, quickly narrowing down where the target could be.
