Searching Flashcards

1
Q

How does binary search work? What are its requirements?

A

Requires sorted array; repeatedly divides in half (O(log n)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When to use Binary Search vs. Ternary Search?

A

Binary Search Ordered arrays or search spaces O(log n)

Ternary Search When function is unimodal (single peak) O(log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly