Discussion Forum on time complexity, self referential structure (Week 2)

Answers

Answers

by Asadur Rahaman Yead -
Number of replies: 0

Ans to the Q no: 1 
 
 
The time complexity of an algorithm is the total amount of time required by an algorithm to complete its execution. ... 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. 
 

 

Ans To the Q no : 2                               

 
line 3:- declare i . 
line 6:- before counter we have to also put ;     (counter = 1 ,counter <= N, counter++); 
line 14:- we have to put ; 
 
 
 

In first for loop we can say it’s = 0 (n+1) 
Then in 2nd step we see that here is 3 nested for loop so this answer is = n*n*n = 0 (n³) . 
 
Final result is = 0(n+1) + 0(n3) = 0 (n³) [ lower power finish ] 

 
The time complexity is n³.