Sorting algorithms - Complexities Flashcards

1
Q

Binary Search - Best case complexity

A

O(1)

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

Binary Search - Best case scenario

A

Target value in middle of array

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

Binary Search - Worst case complexity

A

O(log(N))

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

Binary Search - Worst case scenario

A

Target value either at very start or end of array

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

Insertion Sort - Best case complexity

A

O(N)

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

Insertion Sort - Best case scenario

A

Already sorted

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

Insertion Sort - Worst case complexity

A

O(N^2)

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

Insertion Sort - Worst case scenario

A

Reverse order (Element i > i+1)

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

Selection Sort - Best case complexity

A

O(N^2)

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

Selection Sort - Best case scenario

A

N/A

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

Selection Sort - Worst case complexity

A

O(N^2)

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

Selection Sort - Worst case scenario

A

N/A

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

Merge Sort - Best case complexity

A

O(N log(N))

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

Merge Sort - Best case scenario

A

N/A

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

Merge Sort - Worst case complexity

A

O(N log(N))

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

Merge Sort - Worst case scenario

A

N/A

17
Q

Quick Sort - Best case complexity

A

O(N log(N))

18
Q

Quick Sort - Best case scenario

A

Pivots consistently divide array equally

19
Q

Quick Sort - Worst case complexity

A

O(N^2)

20
Q

Quick Sort - Worst case scenario

A

Devolves into selection sort - pivots useless

21
Q

Radix Sort - Best case complexity

A

O(1)*

Assuming keys are the same length

22
Q

Radix Sort - Best case scenario

A

N/A

23
Q

Radix Sort - Worst case complexity

A

O(1)*

Assuming keys are the same length

24
Q

Radix Sort - Worst case scenario

A

N/A

25
Q

Quick Sort - Average case complexity

A

O(N log(N))