Searching & Sorting 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
What is the difference between Quick Sort and Merge Sort?
A
Quick Sort is in-place, but Merge Sort has better worst-case guarantees.
3
Q
What is the advantage of Heap Sort over Quick Sort?
A
O(n log n) worst-case complexity; always predictable.
4
Q
Why is Bubble Sort not used in practice?
A
O(n²) complexity, too many swaps.
5
Q
What sorting algorithms have O(n) time complexity?
A
Counting Sort, Radix Sort, Bucket Sort (non-comparison-based).
6
Q
What is counting sort, and when is it useful?
A
Good for small, limited-value integers.