We have been taught how to calculate time-complexity for a given algorithm, but how do we do the reverse? For example: write a code to calculate the square of a number with time complexity of theta(n). Any other example will do too.
Asked
Active
Viewed 38 times
0
-
That means you are asked to write a program/algorithm whose complexity shouldn't exceed some limit. There are many examples, you can check this one. https://stackoverflow.com/questions/59399073/reducing-complexity-to-find-the-absolute-sum-of-an-array-elements – User_67128 Jan 07 '20 at 14:48
-
Thank you. I checked it out. Is there anything, in general, I can refer to? – sanjana kumari Jan 13 '20 at 09:16