Alg 2 Flashcards
Meaning of f(n) ∈ O(g(n))
f grows no faster than g
Meaning of f(n) ∈ o(g(n))
f grows strictly slower than g
Meaning of f(n) ∈ Ω(g(n))
f grows no slower than g
Meaning of f(n) ∈ ω(g(n))
f grows strictly faster than g
Meaning of f(n) ∈ Θ(g(n))
f grows at roughly the same rate as g
Formal definition of f(n) ∈ Θ(g(n))
There exist c > 0, C > 0 and n0 > 0 such that for all n ≥ n0, we have cg(n) ≤ f(n) ≤ Cg(n).
Does big O satisfy transitivity?
Yes. if f(n) ∈ O(g(n)) and g(n) ∈ O(h(n)), then f(n) ∈ O(h(n))
Does big O respect addition?
Yes. if f(n) ∈ O(h(n)) and g(n) ∈ O(h(n)), then f(n) + g(n) ∈ O(h(n))
Does big O respect scalar multiplication?
Yes. if f(n) ∈ O(g(n)), then for all constants A > 0, A*f(n) ∈ O(g(n))
Does big O respect multiplication of functions?
No. if f(n) ∈ O(h(n)) and g(n) ∈ O(h(n)), then f(n)·g(n) = O(h(n)) isn’t always true.
Does big O respect squaring?
Yes. if f(n) ∈ O(g(n)), then f(n)2 ∈ O(g(n)2)
Does big O respect expenonentation?
No. if f(n) ∈ O(g(n)), then 2f(n) ∈ O(2g(n)) isn’t always true.
Interval Scheduling
A request is a pair of integers, the start and finish time.
A set of requests is compatible if none of them overlap.
Greedy algorithm: keep choosing compatible interval with earliest finish time. O(nlogn)
Graph Terminology
Two graphs are equal if their vertices and edges are identical.
Two graphs are isomorphic if there exists a mapping between their vertices. (They are the same graph but relabelled)
A subgraph is induced if all edges that connect the sub-vertices in the original graph are also included in the subgraph.
A component of a graph is a maximally connected induced subgraph. E.g. if a graph consists of two triangles, each of those triangles is a separate component.
Euler Walks
A walk is a sequence of connected edges
An euler walk is a walk using each edge exactly once
A path is a walk with no repeated vertices.
A graph cannot have a walk if the number of vertices with an odd degree is not 0 or 2.