3

I am just trying to understand how Big O and Big Omega work. I know that Big O means no better than, and Big Omega means no worse than running times. So if I have a function g(n) such that g(n) = O(f(n)) then can I say that f(n) = Ω(g(n))?

Zong
  • 6,160
  • 5
  • 32
  • 46
Romaldowoho
  • 405
  • 1
  • 7
  • 20

1 Answers1

2

Notation-wise, it is better to write g(n) ∈ O(f(n)), because "O(f(n))" can be seen as the set of all functions that grow no faster than a multiple of f(n).

Let us restate the two relevant formal definitions used in complexity theory:

  • g(n) ∈ O(f(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [|g(n)| ≤ k·|f(n)|]
  • f(n) ∈ Ω(g(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [f(n) ≥ k·g(n)]

If we can assume that f and g are non-negative functions (which is almost always the case for functions used in computer science), then we can drop the absolute value signs. Thus:

  • g(n) ∈ O(f(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [g(n) ≤ k·f(n)]
  • f(n) ∈ Ω(g(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [f(n) ≥ k·g(n)]

Next, flip the inequality on the second logical statement:

  • g(n) ∈ O(f(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [g(n) ≤ k·f(n)]
  • f(n) ∈ Ω(g(n)) ⇔ ∃k>0 ∃N≥0 ∀nN [k·g(n) ≤ f(n)]

Now let's prove that the right-hand side of the first statement implies the right-hand side of the second statement:

  1. Assume that ∃k>0 ∃N≥0 ∀nN [g(n) ≤ k·f(n)] is true.
  2. Instantiate the k>0 that satisfies ∃N≥0 ∀nN [g(n) ≤ k·f(n)].
  3. Let kʹ = 1/k, which is legal because k ≠ 0.
  4. Instantiate the N≥0 that satisfies ∀nN [g(n) ≤ k·f(n)].
  5. Let n be an arbitrary number such that nN.
  6. Then we have g(n) ≤ k·f(n).
  7. Next we have g(n)/kf(n).
  8. By substitution, we have kʹ·g(n) ≤ f(n).
  9. Because n is arbitrary, we derive that ∀nN [kʹ·g(n) ≤ f(n)].
  10. We derive that ∃N≥0 that satisfies ∀nN [kʹ·g(n) ≤ f(n)].
  11. We derive that ∃>0 ∃N≥0 ∀nN [kʹ·g(n) ≤ f(n)].
  12. We rename to k, so that ∃k>0 ∃N≥0 ∀nN [k·g(n) ≤ f(n)].
  13. Thus [∃k>0 ∃N≥0 ∀nN [g(n) ≤ k·f(n)]] implies [∃k>0 ∃N≥0 ∀nN [k·g(n) ≤ f(n)]].
  14. Therefore g(n) ∈ O(f(n)) implies f(n) ∈ Ω(g(n)), as wanted.
Nayuki
  • 17,911
  • 6
  • 53
  • 80