Analysis of Algorithms Flashcards

1
Q

What makes a bad unit test

A

Insufficient - More tests are needed to ensure code quality
Inappropriate - Some tests violate fundamental unit testing rules

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

Rank function from slowest growing to fastest

A

Constant
Logarithm
Polynomial by increasing power
Exponential

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

Adjacency list

A

Node is stored almost like an index where all it’s connections are stored as a list. I.e 0 -> 1->2->4

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

Boyer-moore

A

RT: nm(simplified) n+m(original)
case: worst

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

KMP

A

RT: n+m
case: worst

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

Rabin karp

A

n+m
case: worst

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

Minimum spanning tree

A

RT: m log n for a connected grpah
case: worst

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

Dijkstra

A

RT: m+nlogn
Case: worst

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

Graph traversal: dfs, bfs, in order, preorder, postorder

A

RT: n+M
Case: worst

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

Sorting: comparison based

A

RT nlogn
Case: worst
C

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

When to use Boyer-Moore

A

Boyer-Moore’s algorithm is efficient for long patterns and large texts, especially when the pattern is repetitive or the text has many similar substrings.
This makes it well-suited for searching in English, which has high repetition and redundancy.

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

When to use KMP

A

Knuth-Morris-Pratt’s algorithm is efficient for short patterns and can quickly find a pattern in unprocessed text.
This makes it well-suited for short pattern/text searches where the text is not pre-processed.

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