Asked By
diegobro
0 points
N/A
Posted on - 06/08/2020
Hey experts, Whenever I write an algorithm, I want to know the time complexity of an Algorithm to know its performance.
Please help in checking the time complexity of an Algorithm.
How to check the time complexity of an Algorithm?
Hey, An algorithm is a step by step process of representing the logic of a program in simple English.
- Time complexity: The amount of time taken by a program or an algorithm to run totally is known as time complexity. Through which one can know about the performance of an algorithm or a program.
There are three cases under time complexity:
- Worst case: An algorithm taking a large amount of time for its execution considered the worst case.
- Average case: An algorithm taking the average amount of time for its execution is considered as the Average case.
- Best case: An algorithm taking the lowest amount of time for its execution is considered the best case.
Asymptotic Notations: They are used to calculate the run time of an Algorithm. There are three types of asymptotic notations, they are:
- Big oh notation(O): (worst case) A function f(n) = O(g(n)), there exists a positive integer c and n0, such that |f(n)|<= c|g(n)| for n=> n0.
- Omega(Ω) notation: The function f(n) = Ω(g(n)), there exist positive numbers n0 and c, this |f(n)|=>c|g(n)| for n=>n0.
Â
- Theta notation(Θ): The function f(n) = Θ(g(n)), if there exists three positive constants as c1,c2 and n0 with the constraint c1|g(n)|<=|f(n)|<= c2|g(n)| it is called lower bound.