Quiz 1 Flashcards
If f(n) is in O(kg(n)) for any constant k>0 then
f(n) is in O(g(n))
If f(n) is in O(n) and g(n) is in O(h(n)) then…
f(n) is in O(h(n))
If f1(n) is in g1(n) and f2(n) is in g2(n) then f1(n) + f2(n) is
in O(max(g1(n),g2(n)))
If f1(n) is in O(g1(n)) and f2(n) is in O(g2(n)) then f1(n)f2(n) is
in O(g1(n)g2(n))
Growth ratefastest->slowest
constant, multi log, log, log squared, log^k, linear, nlogn, N^2, N^3, c^N
Form for an algebraic spec
adt NAME uses \_\_\_\_\_ operations: preconditions axioms
Big O
T(N) is (f (N)) if there exists c, n such that T(N) = n. (upper bound)
Big Omega
T(N) is Omega(g(N)) if there exists c, n such that
T(N) >= cg(N) for all N >= n. (lower bound)
Big Theta
T(N) is Theta(h(N)) if and only if T(N)=(h(N)) and
T(N) = Omega(h(N)). (tight bound)
Little o
T(N) is o(p(N)) if for all c there exists n such that
T(N) < cp(N) when N > n. (loose upper bound: T(N)=(p(N))
but T(N) 6 != (p(N)) )
Array - indexing complexity
O(1)
Array - search
O(n)
Dynamic Array - indexing
O(1)
Dynamic Array - Search
O(n)
Dynamic Array - Insertion
O(n)
Dynamic Array - deletion
O(n)
Singly Linked List - indexing
O(n)
Singly Linked List - Search
O(n)
Singly Linked List - insertion
O(1)
Singly Linked List - deletion
O(1)
Doubly Linked List - indexing
O(n)
Doubly Linked List - Search
O(n)
Doubly-Linked List - insertion
O(1)
Doubly-Linked List - deletion
O(1)