Discussion forum week 2(Edited)

.

.

by Rayhanul Amin Nafis (201-15-3164) -
Number of replies: 0

Answer to the qustion no : 1


The time complexity of an algorithm is the total amount of time required by an algorithm to complete its execution.The time take by any kind of code to run is known as the time complexity of that code. The lesser the time complexity, the faster the execution.


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)