Analysis of Algorithms Flashcards
What makes a bad unit test
Insufficient - More tests are needed to ensure code quality
Inappropriate - Some tests violate fundamental unit testing rules
Rank function from slowest growing to fastest
Constant
Logarithm
Polynomial by increasing power
Exponential
Adjacency list
Node is stored almost like an index where all it’s connections are stored as a list. I.e 0 -> 1->2->4
Boyer-moore
RT: nm(simplified) n+m(original)
case: worst
KMP
RT: n+m
case: worst
Rabin karp
n+m
case: worst
Minimum spanning tree
RT: m log n for a connected grpah
case: worst
Dijkstra
RT: m+nlogn
Case: worst
Graph traversal: dfs, bfs, in order, preorder, postorder
RT: n+M
Case: worst
Sorting: comparison based
RT nlogn
Case: worst
C
When to use Boyer-Moore
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.
When to use KMP
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.