Last Minute Flashcards

1
Q

topological sort

A

O(N+M) = O(V+E)

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

DFS/BFS

A

O(M) = O(E) with adj. list.

O(V^2) for adj. matrix

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

non weighted shortest path

A

O(N + M) with adjacency

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

dijkstras

A

with heap O((N+M)lgN) = O(MlgN) = O(ElogV)
with adjlist O(Dv)
with adj matrix O(V^2) = O(N^2)

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

all pairs shortest path

A

O(N^3) with N*O(N^2) dijkstras
with disjkstras heap O(MNlgN)
with dynamic programming we get O(N^3) with better constants

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

transitive closuer

A

N DFS = O(N(N+M))

adj matrix O(N^3)

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

prims-min spanning tree

A

O(ElogV) = O(MlogN)

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

kurskals min spanning tree

A

O(ElogV) = O(MlogN)

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

sum of all degrees for a graph

A

2M

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

undirected graph

A

M <= (N(N-1))/2

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

directed graph

A

M <= N(N-1)

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

connected graph

A

M >= N -1

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

tree

A

M = N -1

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

Forrest

A

M<= N -1

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

Binary tree with h levels

A

2^h -1 nodes

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

each level can hold at most

A

2^i nodes.

17
Q

to hold n nodes

A

logn levels