asymptotic bounding and control structures

47 views Asked by At

So far in my learning of algorithms, I have assumed that asymptotic boundings are directly related to patterns in control structures. So if we have n^2 time complexity, I was thinking that this automatically means that I have to use nested loops. But I see that this is not always correct (and for other time complexities, not just quadratic). How to approach this relationship between time complexity and control structure?

Thank you

1

There are 1 answers

0
David Eisenstat On

Rice's theorem is a significant obstacle to making general statements about analyzing running time.

In practice there's a repertoire of techniques that get applied. A lot of algorithms have nested loop structure that's easy to analyze. When the bounds of one of those loops is data dependent, you might need to do an amortized analysis. Divide and conquer algorithms can often be analyzed with the Master Theorem or Akra–Bazzi.

In some cases, though, the running time analysis can be very subtle. Take union-find, for example: getting the inverse Ackermann running time bound requires pages of proof. And then for things like the Collatz conjecture we have no idea how to even get a finite bound.