Efficiencies: Best Case Minimum Time Required For Program Execution
Efficiencies: Best Case Minimum Time Required For Program Execution
BSCS-2
Efficiencies:
Best Case Minimum time required for program execution.
Notation:
Big Oh Notation, - The (n) is the formal way to express the upper
bound of an algorithm's running time. It measures the worst case time
complexity or longest amount of time an algorithm can possibly take to
complete.
Asymptotic Notation 3
Example: n2 + n = O(n3)
Ex: Proof:
Here, we have f(n) = n2 + n, and g(n) =
n3
Notice that if n 1, n n3 is clear.
Also, notice that if n 1, n2 n3 is
clear.
Side Note: In general, if a b, then na
nb
whenever n 1. This fact is used often in
these
types of proofs.
Therefore,
n2 + n n3 + n3 = 2n3
We have just shown that
n2 + n 2n3 for all n 1
Thus, we have shown that n2 + n =
O(n3)
(by definition of Big-O, with n0 = 1, and c
= 2.)
Guaro Sidney F. BSCS-2
Omega Notation, - The (n) is the formal way to express the lower
bound of an algorithm's running time. It measures the best case time
complexity or best amount of time an algorithm can possibly take to
complete.
Example: n3 + 4n2 = (n2)
Proof:
Here, we have f(n) = n3 + 4n2,
Ex: and g(n) = n2
It is not too hard to see that if
n 0,
n3 n3 + 4n2
We have already seen that if n
1,
n2 n3
Thus when n 1,
n2 n3 n3 + 4n2
Therefore,
1n2 n3 + 4n2 for all n 1
Thus, we have shown that n3 +
4n2 = (n2)
(by definition of Big-, with n0 =
1, and c = 1.)
Theta Notation, - The (n) is the formal way to express both the
lower bound and upper bound of an algorithm's running time.
Ex:
Example: n2 + 5n + 7 = (n2)
Proof:
When n 1,
n2 + 5n + 7 n2 + 5n2 + 7n2
13n2
When n 0,
n2 n2 + 5n + 7
Thus, when n 1
1n2 n2 + 5n + 7 13n2
c2 = 13.)