Major Algorithms Flashcards

1
Q

Depth First Search, DFS (Time)

A

Worst is O(|E| + |V|) for Edges and Vertices

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

Depth First Search, DFS (Space)

A

Worst is O(|V|) for Vertices

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

Breadth First Search, BFS (Time)

A

Worst is O(|E| + |V|) for Edges and Vertices

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

Breadth First Search, BFS (Space)

A

Worst is O(|V|) for Vertices

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

Binary Search (sorted array of n elements) (Time)

A

Average is O(log(n)) and worst is the same

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

Binary Search (Space)

A

Worst is O(1)

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

Linear (Brute Force) search of an array (Time)

A

Average and Worst are both O(n)

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

Linear (Brute Force) search of an array (Space)

A

O(1)

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

Shortest path by Dijkstra,

using a Min-heap as priority queue (Time)

A

Average and Worst are both O((|V| + |E|) log|V|) for Vertices and Edges

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

Shortest path by Dijkstra,

using a Min-heap as priority queue (Space)

A

Worst case is O(|V|) for Vertices

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

Shortest path by Dijkstra,

using an unsorted array as priority queue (Time)

A

Average and Worst are both O(|V|^ 2) for the Vertices

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

Shortest path by Dijkstra,

using an unsorted array as priority queue (Space)

A

Worst is O(|V|) for the Vertices

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

Shortest path by Bellman-Ford (Time)

A

Average and Worst are both O(|V| |E|)

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

Shortest path by Bellman-Ford (Space)

A

Worst is O(|V|)

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

Quicksort(Time)

A

Best and average are O(n log n) Worst is O(n^2)

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

Quicksort (Space)

A

O(n) worst

17
Q

Mergesort (Time)

A

Average, best, and worst are all O(n log n)

18
Q

MergeSort (Space)

A

worst O(n)

19
Q

Heapsort (Time)

A

O(n log n)

20
Q

Heapsort (Space)

A

O(1)

21
Q

Bubble Sort (Time)

A

best O(n), average and worst are O(n^2)

22
Q

Bubble Sort (Space)

A

O(1)

23
Q

Insertion Sort (Time)

A

best O(n) and average/worst are O(n^2)

24
Q

Insertion Sort (Space)

A

O(1)

25
Q

Selection Sort (Time)

A

O(n^2)

26
Q

Selection Sort (Space)

A

O(1)

27
Q

Bucket Sort (Time)

A

O(n + k) for best and average, worst is O(n^2)

28
Q

Bucket Sort (Space)

A

O(nk)

29
Q

Radix Sort (Time)

A

O(nk)

30
Q

Radix Sort(Space)

A

O(n+k)