Final Review Flashcards

1
Q

Time complexity of naive string matcher.

A

Preprocessing = 0
worst matching time = O((n-m+1)m)
Average matching time with few spurious hits = O(n-m + 1)

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

Time complexity of Rabin-Karp

A

Preprocessing = theta(m)

Matching time = O(n-m+1)m)

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

Time complexity of Finite automaton

A

Preprocessing = O(m|E|)
Matching time = theta(n)
Total time including preprocessing =

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

Time complexity of KMP

A

Preprocessing - theta(m)
Matching time = O(n)
Total = O(m+n)

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

Time complexity of adjacency list

A

O(V) + O(E)

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

Time complexity of adjacency matrix

A

O(V^2)

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

Graph Union

A

O(n^2)

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

BFS

A
queueing = O(V)
Total = O(V+E)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

DFS

A

O(V+E)

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

All-pairs shortest paths

A

O(V^3)

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

Matirix Multiplication

A

O(n^3)

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

Quick sort

A

O(nlogn)

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

Binary search

A

O(logn)

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

Linear

A

O(n)

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

Parsing over string twice

A

O(n^2)

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

Dijkstra’s time complexity

A

O(VE + E*log(V))