Design and Analysis Final 01
Design and Analysis Final 01
OF
ALGORITHMS
ASSIGNMENT
ASYMPTOTIC NOTATIONS
Shreya
SAP ID : 500047217
Roll no: 64
TABLE OF CONTENTS-
What is asymptotic notation
Why do we need to use asymptotic notation
Ways to classify asymptotic notation
Classification of asymptotic notation
Big Oh O notation
Big omega(Ω) notation
Theta notation
Small o notation
Small ω notaion
Multiple choice question about asymptotic notation
True and False question about asymptotic notation
WHAT IS ASYMPTOTIC NOTATION?
For example: Imagine that you are running in a 100 m race. After a 30m of
sprint, you are exhausted. After about a 10m of sprint which means 40m you
are more than halfway to your finish line, but you notice you are gradually
slowing down. Another 10m later, you have only sprinted another 1/4 of the
way to final line. Your legs continue to feel heavier and heavier. After another
10m, you are only another 1/8 of the way to finish line. The pattern continues.
As you are sprinting exhausted body drags even more and more, it seems like
you will never get there. Each additional minute only brings you halfway to the
finish line from where you were previously.
Now we have understood what asymptote really means so now we will try to
understand what notation means and will recollect both to understand the
meaning of asymptotic notation.
So, till now we have read about asymptotic notation that it is a tool to
analyse an algorithm’s complexities for change in input size. But the
question that arises after reading about what is asymptotic notation that is
what is the need to use asymptotic notation?
These following points may be helpful in giving us a more clear idea about
the need to use Asymptotic notations-
CLASSIFICATION OF ASYMPTOTIC
NOTATIONS
Now , let’s take a look at each of them step by step that what they are and
how they work and what are their uses and what do we usual take into
consideration more.
BIG O NOTATION-
Some key points about Big O are-
O(g(n)) = {
f(n): there exist positive constants c and
k such that 0 ≤ f(n) ≤ cg(n) for
all n ≥ k
}
In above mathematical format, we have chosen an arbitrary constant ‘k’ as a
standard for large input meaning if our input is considered to be large only
when n ≥ k. After that, we have defined the upper bound for the function f(n)
with the help of a function g(n) and constant c. It means that our function
f(n)’s value will always be less than or equal to c * g(n) where g(n) could be
any non-negative function for all sufficiently large value of n.
Big Oh notation is one of the most widely used notation for finding time
complexity because it usually deals with the upper bound of an algorithm
which helps us to decide which algorithm would be better. For Example:
algorithm of complexity O(n) will do better than algorithm of complexity O(n²)
for sufficiently large input(it may not be true when input is small).
When we say that the running time is "big-O of f(n)” or just "O of f(n)” We
use big-O notation for asymptotic upper bounds, since it is meant to
bound the growth of the running time from above for large enough input
sizes.
BIG OMEGA (Ω) NOTATION-
Ω (g(n)) =
In above mathematical format we can see that the value of function is always
greater than or equal to lower bound which means c * g(n).
Omega notation is widely used when one is interested in the least amount of
time required for the function/algorithm which makes it one of the least
used notation in comparison to other notations.
One can also make accurate but imprecise statements from big-Ω notation.
For example: if we have one lakh rupees in our pocket, we can truthfully say
"I have an amount of money in my pocket, and it's at least 10 rupees." That
is correct, but certainly not very precise.
𝜃-NOTATION(THETA):
that 0 <= c1*g(n) <= f(n) <= c2*g(n) for all n >= n0}
The theta notation bounds a functions from above and below, so it defines
exact asymptotic behaviour .A simple way to get Theta notation of an
expression is to drop low order terms and ignore leading constants. For
example, consider the following expression.
The above definition means, if f(n) is theta of g(n), then the value f(n) is
always between k1*g(n) and k2*g(n) for large values of n (n >= n0). The
definition of theta also requires that f(n) must be non negative for values of n
greater than n0.
Example:
2 2
If n +3n+4=Θ(n )
Proof:
When n ≥ 1, n2 + 3n + 4 ≤ n2+ 3n2+ 4n2 ≤ 8n2
• When n ≥ 0, n2 ≤ n2 + 3n + 4
• Thus, when n ≥ 1 1n 2 ≤ n2 + 3n + 3 ≤ 8n2
2
Thus, we have shown that n2+3n+4= Θ(n )
SMALL o NOTATION:
Let f(n) and g(n) be functions that map positive integers to positive real
numbers. We say that f(n) is ο(g(n)) (or f(n) Ε ο(g(n))) if for any real constant c
> 0, there exists an integer constant n0 ≥ 1 such that 0 ≤ f(n) < c*g(n).
f(n)=o(g(n))
means
limf(n)/g(n)=0
n→∞
Examples:
Is 6n + 7 ∈ o(n2)?
In order for that to be true, for any c, we have to be able to find an n0 that
makes
f(n) < c * g(n) asymptotically true.
If c = 100,we check the inequality is clearly true. If c = 1/100 , we’ll have to use
a little more imagination, but we’ll be able to find an n0. (Try n0 = 1000.) From
these examples, the conjecture appears to be correct.
then check limits,
lim f(n)/g(n) = lim (6n + 7)/(n2) = lim 6/2n = 0 (l’hospital)
n→∞ n→∞ n→∞
SMALL ω NOTATION:
if f(n) ∈ ω(g(n))
then,
lim f(n)/g(n)=∞
n→∞
Let f(n) and g(n) be functions that map positive integers to positive real
numbers. We say that f(n) is ω(g(n)) (or f(n) ∈ ω(g(n))) if for any real constant
c > 0, there exists an integer constant n0 ≥ 1 such that f(n) > c * g(n) ≥ 0 for
every integer n ≥ n0.
f(n) has a higher growth rate than g(n) so main difference between Big
Omega (Ω) and little omega (ω) lies in their definitions.In the case of Big
Omega f(n)=Ω(g(n)) and the bound is 0<=cg(n)<=f(n), but in case of little
omega, it is true for 0<=c*g(n)<f(n).
Example:
3n+5 ∈ ω(1);
the little omega(ο) running time can be proven by applying limit formula
given below.
n→∞
and,also for any c we can get n0 for this inequality 0 <= c*g(n) < f(n), 0 <=
c*1 < 3n+5
Hence proved.
1.For the functions, n^k and c^n, what is the asymptotic relationship
between these functions? Assume that k >= 1 and c > 1 are constants.
a.)lgn is O(log_8n)
b.)lgn is Ω(log_8n)
c.)lgn is Θ(log_8n)
3.) For the functions log2 n and log8 n what is the asymptotic relationship
between these functions?
8.) To verify whether a function grows faster or slower than the other
function, we have some asymptotic or mathematical notations, which
is_________.
a.) Big Omega Ω (f)
b.) Big Theta θ (f)
c.) Big Oh O (f)
d.) All of the above
9.) A function in which f(n) is Ω(g(n)), if there exist positive values k and c
such that f(n)>=c*g(n), for all n>=k. This notation defines a lower bound for a
function f(n):
a.) Big Omega Ω (f)
b.) Big Theta θ (f)
c.) Big Oh O (f)
d.) All of the above
10.) An algorithm that indicates the amount of temporary storage required
for running the algorithm, i.e., the amount of memory needed by the
algorithm to run to completion is termed as_____.
a.) Big Omega Ω (f)
b.) Big Theta θ (f)
c.) Big Oh O (f)
d.) All of the above
1.)An algorithm performs lesser number of operations when the size of input
is small, but performs more operations when the size of input gets larger.
State if the statement is True or False or Maybe.
a.) True
b) false
c) maybe
d) none of the above
Decide whether these statements are True or False. You must briefly justify
all your answers to receive full credit.