Binary Search + Preconditions Flashcards
(3 cards)
1
Q
What is binary search?
A
More efficient than linear
compares the middle item to the searched for target item, if the values match then the index is returned.
if the middle item is larger, the top half of the list is ignored
repeat
2
Q
What does the list have to be for a binary search to be possible?
A
Sorted
3
Q
Binary search benefits
A
Very efficient
time complexity of 0(logn)