Searching Flashcards
1
Q
How does binary search work? What are its requirements?
A
Requires sorted array; repeatedly divides in half (O(log n)).
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)