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)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

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

What is the advantage of Heap Sort over Quick Sort?

A

O(n log n) worst-case complexity; always predictable.

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

Why is Bubble Sort not used in practice?

A

O(n²) complexity, too many swaps.

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

What sorting algorithms have O(n) time complexity?

A

Counting Sort, Radix Sort, Bucket Sort (non-comparison-based).

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

What is counting sort, and when is it useful?

A

Good for small, limited-value integers.

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