What does bounding a function from both sides buy you, and why can Theta throw away every term but the dominant one?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Theta asks two things of the same g: c0 times g(x) stays at or above f(x) from x0 on, and c1 times g(x) stays at or below f(x) from x1 on. Check each condition at every whole number from its own threshold up to and including 1000 (all() and range() may help); the video's f () and g () are already defined. Define pinned(f, g, c0, x0, c1, x1) returning True only when both conditions hold.
# the video's cost function and its bounding function
def f(x):
return 3 * x**2 - 20 * x - 1
def g(x):
return x**2The two-sided definition of
Write both conditions with constants and on the same , then show and solve for the lower bound's crossover .
Tightness: one Theta versus many Big O bounds
State that is the fastest-growing term without its constant, show fails the lower-bound condition for any constant, and list several valid Big O bounds for beside its single .
Simplifying a formula to its order of growth
Write the rule: keep the dominant term, drop its multiplicative constant, drop every other term; then apply it to , and , noting that even is dropped.
Stating Theta in terms of the actual input
Record the rule against reporting in by default, then find the Theta of when the input is , , both, or a variable absent from the formula.