Complexities Flashcards

1
Q

What is the complexity for BST

A

Best case search O(1)
Worst case (LL) O(n)
Average case O(logn)

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

Max heap height?

A

O(log n)

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

Heap Creation.
Bottom Up
Top Down

A

O(n) worst case
O(nlogn) worst case

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

Adjacency List
Adjacency Matrix

A

O(|V| + |E|)
O(|V|^2)

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

Topological Sort

A

O(|V|+|E|)

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

Dijkstra’s Algorithm

A

O(|V|^2)
heap: O((|E|+|V|)+log|V|)
shortest path between all pairs O(|V|^3)

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

Kruskal’s Algorithm

A

number of edges = |V| - 1
O(|E|log|V|)

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

Prim’s Algorithm

A

Simple algorithm: O(|V|^2)
Heap: O(|E|log|V|)

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

Hashing Function

A

O(1)

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

Separate chaining

A

Accessing/Finding List O(1)
Finding a key O(n)

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