Sorting Algorithms Flashcards

1
Q

What are the Non-Recursive/Incremental Comparison Sorting Algorithms?

A
  • Selection Sort
  • Bubble Sort
  • Insertion Sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Best, Worst, and Average Case of Selection Sort Algorithm?

A

Best: O(n^2)
Worst: O(n^2)
Average: O(n^2)

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

What are the Best, Worst, and Average Case of Bubble Sort Algorithm?

A

Best: O(n^2)
Worst: O(n^2)
Average: O(n^2)

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

What are the Best, Worst, and Average Case of Modified Bubble Sort Algorithm?

A

Best: O(n)
Worst: O(n^2)
Average: O(n^2)

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

What are the Best, Worst, and Average Case of Insertion Sort Algorithm?

A

Best: O(n^2)
Worst: O(n^2)
Average: O(n^2)

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

What are the Recursive Comparison Sorting Algorithms?

A
  • Merge Sort
  • Quick Sort
  • Heap Sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the Best, Worst, and Average Case of Merge Sort Algorithm?

A

Best: O(nlogn)
Worst: O(nlogn)
Average: O(nlogn)

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

What are the Best, Worst, and Average Case of Quick Sort Algorithm?

A

Best: O(nlogn)
Worst: O(n^2)
Average: O(nlogn)

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

What are the Best, Worst, and Average Case of Heap Sort Algorithm?

A

Best: O(nlogn)
Worst: O(nlogn)
Average: O(nlogn)

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

When should you use Strategy 1 (Pick the First Element in S) when picking a pivot?

A

If input is random and not sorted

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

When should you use Strategy 2 (Pick the Pivot Randomly) when picking a pivot?

A

Random Number Generation is an expensive operation

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

How do you find the pivot in Strategy w (Median-of-Three Partitioning)?

A

Median of the left-most, right-most, and center elements of array S

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

What happens to Quick Sort when the array contains multiple duplicate elements?

A

Unstable

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

What is the theorem for lower-bound comparison sorting?

A

To sort n elements, comparison sorts must make Ω(nlgn) comparisons in the worst case.

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