it is long time since last time I wrote a blog post , I'm Okay and passion to write more and more posts , I'll talk about measuring efficiency of Algorithms .
there exist two approaches :
- using the Concept of bench mark we focus on two aspects :
- is the output of the program correct ?
- how much time and resources are needed by the program to produce the correct output?
- estimate ! DON'T MEASURE , and we will talk about this approach in details in the next sections.
we gonna use a new term " Asymptotic Analysis ":
Asymptotic analysis is an analytical approach to analyze the running time of the algorithms under the following assumptions :
- the size of the input .
- estimating the number of steps required to run an Algorithm we neglect the primitive operations.
there exist many notation used for estimating performance in asymptomatic analysis :-
- Big O notation .
- small o notation .
- Big Theta notation .
- Big Omega notation.
- small omega notation .
- 1000 , 5 n , log (n) , 1/2 n are all Big-Oh of n, O ( n )
- 10 , 2n , n^2 , 10000 n^2 are all O (n^2)
- Constant growing function O (1)
- Logarithmic growing function O ( log n)
- Linear growing function O ( n )
- n log n growing function O ( n log n )
- Quadratic growing function O (n^2)
- Polynomial growing function O ( n^k ) where k is constant
- Exponential growing function O (2^n)
The Formal Definition of the Big - Oh
- We say that t(n)=O(f(n)) if and only if there are two nonnegative constants no and c such that t(n)≤cf(n) for all n≥no and c>0
- The expression t(n)=O(f(n)) is read as
- T of n is in Big-Oh of f of n,
- T of n is in the set Big-Oh of f of n,” or
- T of n is Big-Oh of f of n.
- The definition means that if the problem size n equals or exceeds no, t(n) will be bounded from above by cf(n), i.e. the value cf(n) will eventually exceed the value of t(n) when n>=no
there exist two approaches to show that a function t ( n ) is in O ( n )
- By showing that there exists two nonnegative numbers no and c such that t(n) ≤ cf(n) for all n ≥ no
- For really large n, we can use the limit
theorem to show that there exists a nonnegative number c<∞ such that
example 3 :
example 4 :
I finished Big-Oh in shaa Allah I'll complete the others soon , I hope you like the Article , and if you like it please can you share it .
this Article main source is PhD / Ahmed Kamal lecture slide , thank you for reading :)
this Article main source is PhD / Ahmed Kamal lecture slide , thank you for reading :)
to be Continued ........................
Comments
Post a Comment