Bifalgorithm post
Searching a number in 1 million items in just 20 steps. This is binary search. Imagine finding a word in a dictionary. Do you start from page 1? No. You open the middle page first. So, binary search works the same way. It checks the middle element if the value is bigger then it goes right if the value is smaller then it goes left. But remember one rule. Binary search works only on a sorted array. Linear search checks one by one and binary search scores the list in half every time. So this is why binary search is asked in every coding interview.
Searching a number in 1 million items in just 20 steps. This is binary search. Imagine finding a word in a dictionary. Do you start from page 1? No. You open t…
Ideas in this flowchart
- Binary Search Explanation
- Concept of Binary Search
- Efficient Search
- Comparison to Linear Search
- Example: Dictionary Search
- Process of Binary Search
- Sorted Array Requirement
- Middle Element Check
- Go Right if Bigger
- Go Left if Smaller
- Binary Search in Interviews
- Step Reduction