Discussion forum week 2(Edited)

Click here

Re: Click here

by Mafujul Haque Plabon -
Number of replies: 0
Picture of DS-(PC-J) Picture of DSLab-(PC-J)
Answer to the question no(1)


The time complexity of an algorithm is the total amount of time required by an algorithm to complete its execution. In simple words, every piece of code we write, takes time to execute. The time taken by any piece of code to run is known as the time complexity of that code. The lesser the time complexity, the faster the execution.aratē pāraba.
We can find out the minimum or maximum time taken by any algorithm through time complexity. As a result, I can use the program efficiently.

Answer to the question no (2)
At first we have to fix some problems of this code.
• We have to declare i in the 3rd line
• We have to use a for loop before the counter
• We will have to put a ; in line 14
In the first loop, it will be = O(n+1)
In the second loop, it will be = O(n2)
then in the third loop it will be= O(Logn)
the final result will be=O(n+1)+O(n2)+O(Logn)= O(n2)
[Lower power finish] [. Higher power acceptable]
So the complexity during the program is n^2