PS2 FAQ
- Can I just graph the functions to determine which is the upper bound of the other?
Graphing may help give you some intuition/understanding, but it's not a proof. When you're comparing two functions, do the same operation to both (e.g., divide by something, take the log of it) and then see if it's obvious which of the reduced functions is smaller. (Why can you compare the reduced functions and draw conclusions about the original functions?)
Justify your answers/order. You will probably just need to justify each ordered pair since, by transitivity, we'll know that the order holds.
Look at the solved exercises at the end of Chapter 2 for additional guidance.
- Can I have a hint on part b of problem 2.6?
First, run though the algorithm using a small example--say, with A having four elements. (This is general advice for the whole problem.)
Show that, no matter what, you need to do a certain number of calculations--even if you look at just part of the algorithm.
I think what makes this problem tricky is that you are used to finding the upper bounds, so you want to do that.
- I'm confused by the limit in part c of problem 2.6. Do I need to find the limit using l'Hôpital's rule?
No, you don't need to find the limit. The problem is that students will find an algorithm whose runtime is, say, O(n^2), and then an improved algorithm that is O(n^2-1000). However, the limit of (n^2-1000)/n^2 is not 0 but 1. (Why?) Your improved algorithm should be a significant improvement over the original algorithm.
If you're having trouble, I recommend that you implement both the original and your improved algorithm (using the starter code provided on the course web page) so that you'll see the true running time of the original algorithm and will improve your chances of creating a correct improved algorithm.