7: Analysis Flashcards
What is the regularity condition?
From the Master Theorem, when a problem has af * (n / b) <= c * f(n) for a sufficently large n and a constant c < 1.
Give the notations for best, worst, and average complexities
Best case = Θ(n), exact upper bound
Average case = O(n), rough upper bound
Worst case = Ω(n), lower bound
What is loop hoisting?
Trying to refactor program loigic to remove loops to optimise complexity/ies.
What is the third simplifying rule?
If some functions g and h are upper/lower bounds for a cost, then their max or min is also an upper/lower bound for that cost.
If f = O(g), and f = O(h), then f = O(max(g, h)), f = O(min(g, h))
If f = Ω(g), and f = Ω(h), then f = Ω(max(g, h)), f = Ω(min(g, h))
If f = Θ(g), and f = Θ(h), then f = Θ(max(g, h)), f = Θ(min(g, h))
What are sort keys?
Fields in items in a list that dictate the order of the list. In a database they are fields and a type of key (e.g. primary).
What is the Master Theorem for divide-and-conquer recurrences?
Provides a general form of divide-and-conquer recurrences and 3 cases for them that must hold.
What would P != NP actually mean?
Each NP problem would have a superpolynomial lower bound of complexity.
What are P problems? What does P stand for?
P problems have proofs showing they can be solved in polynomial time by a deterministic TM. P stands for polynomial; since no N for nondeterministic, “P” problems are deterministically (and therefore also nondeterministically) solvable within polynomial (P) time.
What is verification?
Verification is checking against previously found results, e.g. facotorials of BigIntegers in a HashMap in Java so you don’t need to recalculate each time.
What are NP-hard problems?
NP-hard problems are all problems that NP problems can be reduced to in polynomial time by a deterministic TM.
What are NP-complete problems?
NP-complete problems are problems in both NP and NP-hard. They have no existing proof they can be done in polynomial time by a deterministic TM, have a proof they can be verified in polynomial time by a deterministic TM, and can be reduced to from NP problems in polynomial time by a deterministic TM.
Note verification is checking against previously found results, e.g. facotorials of BigIntegers in a HashMap in Java so you don’t need to recalculate each time.
What do divide and conquer algorithms do?
Recursively divide problems into smaller subproblems, before solving (“conquering”) the original larger problem by combining the results of solving the subproblems.
What is a recurrence relation?
Recurrence relations are equations defining each element in sequences as a function of the preceding ones. They are used to define recursive functions.
What is the mathematical definition of a recurrence relation?
T(x) = time taken for input size x
T(n) depends on T(m) where m < n: the time taken for each problem size depends on the size 1 less (and thereby all problem sizes smaller than it).
How can you find the complexity of an algorithm from its recurrence relation?
Expand it and then apply known solutions or repeatedly guess and then verify possible complexities, usually by induction: trial and error.