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

Discussion Forum (Week 2)

Discussion Forum (Week 2)

by Jannatul Ferdous Moon -
Number of replies: 0

Ans to the question no : 1 


 Time complexity in computer science is the complexity of computation that describes the time it takes to run an algorithm.  Time complexity is usually estimated by calculating the initial activities performed by the algorithm, assuming that each initial activity takes a certain amount of time to perform.  Thus, the initial activity performed by time and algorithms is separated by the most constant factor. 



Ans to the question no : 2 


 This code contains bug.These are some problems that I found -

In line 3:- we have to declare i

In line 6:- before counter we have to also put for

In line 14:- we have to put ; in last printf (“hello”) ;


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³.