Write String Sinusoidally 6.11 (Python)

#1

The solution states… ‘each of the iteration takes O(n) time…’

Its clear that this is a linear time algorithm. However, to be more rigorous, isn’t each iteration doing better than O(n)? Since in each for loop, we are not checking each and every value in the string, we are actually jumping indices.

Thoughts?

0 Likes

#2

Hi @Denace,

Yes, each of the iteration is doing operation less than n. However, if we are using time complexity perspective, it is O(n). The total number of operations is n for those three iterations.

1 Like