I am running into a lot of trouble in learning how to compute time complexity, particularly when you have nested loops where the inner loop variable is interdependent. How do you approach such problems? What kind of resources(books, websites, Youtube channels, etc) would you recommend to be able to tackle these kinds of problems?
How to approach finding time complexity of an algorithm that includes loops with dependent variables
Asked
Active
Viewed 111 times
0
-
You have to analyse the lower bound and upper bound of the independent variable.Based on that you can have the range for dependent variable.Then use summation rules to find out the time complexity – bigbounty May 07 '17 at 20:36
-
would you be willing to perhaps show me an example of how you would do this? Do you recommend any resources? – BillyBob1 May 07 '17 at 20:40
-
1Possible duplicate of [Big O, how do you calculate/approximate it?](http://stackoverflow.com/questions/3255/big-o-how-do-you-calculate-approximate-it) – Paul Hankin May 07 '17 at 20:43
-
1Ok,please refer to the book CLRS book.Best book for algorithms.http://is.ptithcm.edu.vn/~tdhuy/Programming/Introduction.to.Algorithms.pdf – bigbounty May 07 '17 at 20:46
-
1Also go through interviewbit.com phase1,they have good questions on time complexity – bigbounty May 07 '17 at 20:47
-
Thanks bigbounty – BillyBob1 May 07 '17 at 21:23