What is binary search and when can you apply it?
LeetCode Patterns Flashcards: Binary Search, Search Space, Templates, Edge Cases
Аудио-карточка · 0:23Nortren·
What is binary search and when can you apply it?
0:23
Binary search eliminates half the search space at each step by comparing the target with the middle element and deciding which half to continue searching. It applies whenever the search space has a monotonic property where all elements on one side satisfy a condition and all on the other do not. The input does not have to be a sorted array. Binary search works on any decision function that transitions from false to true or true to false at some boundary point.
neetcode.io