Algorithm Analysis Examples 1
For Complete YouTube Video: Click Here
In this class, we will try to understand Algorithm Analysis Examples 1.
We have already discussed the concepts of time complexity in our previous classes.
Table of Contents
Algorithm Analysis Examples 1
We will consider the following algorithms and analyze them.
Algorithm 1
Below is Algorithm 1.
The above algorithm is to find the sum of two elements.
The algorithm will execute only one line of code to get the output.
We change the input n number of times we will get out in a constant amount of time.
Algorithm 2
The above algorithm is to find whether the number is even or odd.
This algorithm will also take a constant amount of time to get the output.
Algorithm 3
The above algorithm is to find the first element of an array.
Whatever the array size to find the first element, it will run only two lines of code.
Algorithm 4
The above algorithm is to print the first n numbers.
To get the output, the for loop will iterate for n number of times.