Asymptotic notation is used to analyze the efficiency of algorithms as the input size grows. There are three main notations: O notation provides an asymptotic upper bound and models worst-case analysis; Ω notation provides an asymptotic lower bound and models best-case analysis; Θ notation provides both asymptotic upper and lower bounds and models average-case analysis. Examples are given to demonstrate how functions fit into each notation based on growth rate comparisons as n approaches infinity.
Asymptotic notation is used to analyze the efficiency of algorithms as the input size grows. There are three main notations: O notation provides an asymptotic upper bound and models worst-case analysis; Ω notation provides an asymptotic lower bound and models best-case analysis; Θ notation provides both asymptotic upper and lower bounds and models average-case analysis. Examples are given to demonstrate how functions fit into each notation based on growth rate comparisons as n approaches infinity.
Asymptotic notation is a notation, which is used to take meaningful statement about
the efficiency of a program. The efficiency analysis framework concentrates on the order of growth of an algorithm’s basic operation count as the principal indicator of the algorithm’s efficiency. To compare and rank such orders of growth, computer scientists use three notations, they are: O - Big oh notation Ω - Big omega notation Θ - Big theta notation Let t(n) and g(n) can be any nonnegative functions defined on the set of natural numbers. The algorithm’s running time t(n) usually indicated by its basic operation count C(n), and g(n), some simple function to compare with the count.
Example 1:
where g(n) = n2.
(i) O - Big oh notation A function t(n) is said to be in O(g(n)), denoted if t (n) t(n) ∈ O(g(n)),t(n) is bounded above by some constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 such that t (n) ≤ cg(n) for all n ≥ n0.
Where t(n) and g(n) are nonnegative functions defined on the set of natural numbers. O = Asymptotic upper bound = Useful for worst case analysis = Loose bound
FIGURE 1.5 Big-oh notation:
Example 2: Prove the assertions
Proof: 100n + 5 ≤ 100n + n (for all n ≥ 5) = 101n ≤ 101n2 Since, the definition gives us a lot of freedom in choosing specific values for constants c and n0. We have c=101 and n0=5 Example 3: Prove the assertions Proof: 100n + 5 ≤ 100n + 5n (for all n ≥ 1) = 105n i.e., 100n + 5 ≤ 105n i.e., t(n) ≤ cg(n)
(ii) Ω - Big omega notation
A function t(n) is said to be in Ω(g(n)), denoted t(n) ∈ Ω(g(n)), if t(n) is bounded below by some positive constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some nonnegative integer n0 such that t (n) ≥ cg(n) for all n ≥ n0. Where t(n) and g(n) are nonnegative functions defined on the set of natural numbers. Ω = Asymptotic lower bound = Useful for best case analysis = Loose bound
FIGURE 1.6 Big-omega notation: t (n) ∈ Ω (g(n)).
Example 4: Prove the assertions n3+10n2+4n+2 ∈ Ω (n2).
Proof: n3+10n2+4n+2 ≥ n2 (for all n ≥ 0) i.e., by definition t(n) ≥ cg(n), where c=1 and n0=0
(iii) Θ - Big theta notation
A function t(n) is said to be in Θ(g(n)), denoted t(n) ∈ Θ(g(n)), if t(n) is bounded both above and below by some positive constant multiples of g(n) for all large n, i.e., if there exist some positive constants c1 and c2 and some nonnegative integer n0 such that c2g(n) ≤ t (n) ≤ c1g(n) for all n ≥ n0. Where t(n) and g(n) are nonnegative functions defined on the set of natural numbers. Θ = Asymptotic tight bound = Useful for average case analysis
FIGURE 1.7 Big-theta notation: t (n) ∈ Θ(g(n)).
Note: asymptotic notation can be thought of as "relational operators" for functions similar to the corresponding relational operators for values. = ⇒ Θ(), ≤ ⇒ O(), ≥ ⇒ Ω(), < ⇒ o(), > ⇒ ω()