Sunday, March 17, 2013

week 8

This week we learn about worst case complexity and how to calculate it by counting steps.

Every function has an upper bound and lower bound so that we always consider the worst case --- the upper bound for complexity.
Since complexity is going to be a very large number, the constant in it really doesn't matter any more. For example, O(18n^2) roughly is O(n^2).

For calculating the steps of a function, we count the constant steps first and then count the outer loop(let's say n steps) and then the Loop Guard and then the inner loop(lets say n^2) and so on.

No comments:

Post a Comment