Ada - Module 1
Ada - Module 1
increases. It's used to compare the performance of different algorithms. Basic efficiency classes describe the running
time of an algorithm.
Asymptotic notation
• Big O: Used to describe the worst-case running time of an algorithm
• Big Omega: Used to describe the best-case running time of an algorithm
• Big Theta: Used to describe when the running time is the same for all cases
The asymptotic behavior of an algorithm is defined by the highest degree polynomial term of its complexity function.
1.Big-Oh notation:-
Definition: A function t(n) is said to be in O(g(n)), denoted t(n)∈O(g(n)), if 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 n 0 such that
t(n) ≤ c g(n) for all n ≥ n0.
Informally, O(g(n)) is the set of all functions with a lower or same order of growth as g(n)
2. Big-Omega notation:-
Definition: 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., positive constant c and some nonnegative
integer n0 such that
t(n) ≥ c g(n) for all n ≥ n0.
3. 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
c2 g(n) ≤ t(n) ≤ c1g(n) for all n ≥ n0.
Benefits of asymptotic notation
•For example, if the dominant term is n^2, the Big O notation would be O(n^2).
Polynomial O(n^c) Strassen’s Matrix Multiplication, Bubble Sort, Selection Sort, Insertion Sort, Bucket Sort
Factorial O(n!) Determinant Expansion by Minors, Brute force Search algorithm for Traveling Salesman Problem
In each notation:
•f(n) represents the function being analyzed, typically the algorithm’s time complexity.
•n0 is the minimum input size beyond which the inequality holds.
These notations are used to analyze algorithms based on their worst-case (Big O), best-case (Ω),
and average-case (θ) scenarios.
f we plot the most common Big O notation examples, we would have graph like this: