Sorting Time Complexities Flashcards

1
Q

Quick Sort

A
  • Best Case: O(nlogn)
  • Average Case: O(nlogn)
  • Worst Case: O(n²) (if the pivot is consistently the smallest or largest)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Merge Sort

A
  • Best Case: O(nlogn)
    -Average Case: O(nlogn)
  • Worst: O(nlogn)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Bubble Sort

A
  • Best: O(n)
  • Worst: O(n^2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Insertion Sort

A
  • Best Case: O(n) (when the array is already sorted)
  • Worst Case: O(n²) (when the array is in reverse order)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Selection Sort

A
  • Best Case: O(n²) (when the array is already sorted)
  • Worst Case: O(n²) (when the array is in reverse order)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Tree Sort

A
  • Best Case: O(nlogn)
    -Average Case: O(nlogn)
  • Worst: O(nlogn)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Heap Sort

A
  • Best Case: O(nlogn)
    -Average Case: O(nlogn)
  • Worst: O(nlogn)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Bucket Sort

A
  • O(n) to place n items into buckets, plus O(n) to concatenate if n > d
  • O(d) if n < d. Typically O(n) in practice.

d - amount of empty buckets

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

Radix Sort (MSD)

A
  • O((n + R) · (max. length of key))
  • O(n + R) when maximum key length is constant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Radix Sort (LSD)

A
  • O((n + R) · (max. length of key)),
  • O(n + R) when key length is fixed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly