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

Discussion

Discussion

by Anika Nawar -
Number of replies: 0

1)Time complexity is simply a measure of the time it takes for a function or expression to complete its task, as well as the name of the process to measure that time. It can be applied to almost any algorithm or function but is more useful for recursive functions.


2) in line 3-we have to declare i

line 6- before counter we have to add for

line 14- ; in the printf function printf (“hello”) ; would be used.

In first for loop it is = 0 (n+1)

After that in second term it is clear that here is three nested for loops,thats why the answer might be is = n*n*n = 0 (n³)


Finally result is = 0(n+1) + 0(n3) = 0 (n³)


The time complexity is n³