Untitled Document
Untitled Document
Time complexity is a concept used in computer science to describe how the running time of an
algorithm or a program increases as the size of the input grows. It provides a way to evaluate
and compare the efficiency of different algorithms in terms of how they handle larger inputs.
By analyzing time complexity, you can better understand the performance characteristics of
algorithms and make more informed decisions about which algorithm to use for a particular
problem.
Asymptotic notations are mathematical tools used to describe the behavior of functions,
particularly in the context of algorithm analysis, as the size of the input grows toward infinity.
They provide a way to classify algorithms according to their running time or space requirements
in terms of their growth rates. asymptotic notations are crucial for analyzing and comparing
algorithms, providing a clear understanding of their performance characteristics as input sizes
become very large. They allow you to describe algorithms in terms of their efficiency and
scalability.
3.Calculate the time complexity of the following algorithm, identify if its Constant
complexity or Linear complexity and draw graph to show support your answer.
1.{
int i, n = 8;
for (i = 1; i <= n; i++) {
printf("Hello Word !!!\n");
}
}
The time complexity of the given algorithm is O(n), which means it has
linear complexity.
2.Sum(a,b){
return a+b
}
Since the execution time does not depend on the size or number of inputs,
the time complexity is O(1) which is referred to as constant time complexity.
Time (T(n))