What is Time Complexity of an Algorithm
For Complete YouTube Video: Click Here
This class will try to understand What is Time Complexity of an Algorithm.
We have already discussed “why algorithm analysis is required” in our previous classes.
What is Time Complexity of an Algorithm
Time Complexity: The Time Complexity of an algorithm is the amount of computer time it needs to run to completion.
Though the definition of the time complexity looks straightforward, understanding this in-depth is covered in the following 4 to 5 classes.
To understand this consider the algorithm shown below.
In the above algorithm, consider only the first line code.
sum = a + b;
Though it looks like just one single line of code to execute this, the compile will run many micro-operations.
First, variable a has to be loaded, and then variable b must be loaded.
Now, “a + b” is done in ALU, and then the sum value is stored in the sum location.
There are many different factors to be considered to find the time complexity of an algorithm.
These factors are not constant all the time.
They will change from one instance to another instance.
The kind of factors is called instance characteristics.
To find an algorithm’s time complexity, we will consider only the program step.
In the next class, we will discuss the program step.