There are two ways to find the Ideal Algorithms for any particular problem as given below:-
- Time:-An algorithm is good which takes less time.
- Space:-An algorithm is good which takes less space(storage).
The efficiency of any algorithms fully dependent on time,space and other resources which are needed to execute any algorithms.
Asymptotic Notations:-
Asymptotic notations are the mathematical notations.It is used to represent the complexity of algorithms.This allows us to analyze an algorithm's running time and its behaviors. There are mainly three asymptotic notations to find the complexity of algorithms as given below:-
- Big O Notation
- Big Ω (omega) Notation
- Big Θ (theta) Notation
1.) Big O Notation:-
Big O notation always represents the upper bound of running time of any algorithms. To represent the worst case complexity we always use Big O notation.Big o notation always talk about worst case complexity of an algorithm.
X Axis Represents--> Input data
Mathematical formula:-
f(n)<=c.g(n)
n>=n0
c>0,n0>=1
f(n)=O(g(n))
f(n)=Big O of g(n)
Descriptions:-
- f(n) always less than or eual to c.g(n).
- c,n is a constant that is always greater than zero.
- n0 is greater than or equal to 1.
Note:-If we are talking about Big O notation,two pictures comes in our mind.
- Upper Bound
- Worst case
e.g.
# Find the 50 element in given array using Linear search .
Time complexity =O(9)
2.) Big Ω (omega Notation:-
Big Ω notation always represents the lower bound of running time of any algorithms.To represent the best case complexity we always use Big Ω notation.Big Ω notation always talk about best case complexity of an algorithm.
Y Axis Represents--> Time
X Axis Represents--> Input data
Mathematical formula:-
f(n)>=c.g(n)
n>=n0
c>0,n0>=1
f(n)=Ω(g(n))
f(n)=Big Ω of g(n)
Descriptions:-
- f(n) always greater than or eual to c.g(n).
- c,n is a constant that is always greater than zero.
- n0 is greater than or equal to 1.
Note:-If we are talking about Big Ω notation,two pictures comes in our mind.
- Lower Bound
- best case
e.g.
# Find the 15 element in given array using Linear search .
When we start search 15 element in array, we find this element at the first index of the array.This is a best case for searching this element.Big Ω Notation represents the best case complexity.
Time complexity =Ω(0)
3.) Big Θ (theta) Notation:-
Big Θ notation represents the average case time complexity of an algorithm.
Y Axis Represents--> Time
X Axis Represents--> Input data
Mathematical formula:-
c1.g(n)<=f(n)<=c2.g(n)
n>=n0
c1,c2>0
n0>=1
f(n)=Θ(n)
f(n)=Big Θ of g(n)
Note:-If we are talking about Big Θ notation,one pictures comes in our mind.
- Average value (present in middle part)
e.g.
# Find the average marks of 12 students out of 100 marks.
In above table ,Average Marks of 12 students =53.33 which presents between 1 to 100. Big Θ Notation is used to represents the average case.so time complexity of this will represent by Big Θ Notation.
f(n)>=1 & f(n)<=100
1<=f(n)<=100
Time complexity =Θ(53.33)
Watch Complete Lecture Video:-
For More...
0 comments:
Post a Comment