Link

Iterative Algorithm Analysis Study Guide

Runtime Analysis. Understanding the runtime of code involves deep thought. It amounts to asking: “How long does it take to do stuff?”, where stuff can be any conceivable computational process whatsoever. It simply cannot be done mechanically, at least for non-trivial problems. As an example, a pair of nested for loops does not automatically result in Theta(N2) runtime.

Cost Model. As an anchor for your thinking, recall the idea of a “cost model” from last lecture. Pick an operation and count them. You want the one whose count has the highest order of growth as a function of the input size.

Important Summations. This is not a math class so we’ll be a bit sloppy, but the two key sums that you should know are that:

  • 1 + 2 + 3 + … + N is in Theta(N2)
  • 1 + 2 + 4 + 8 + … + N is in Theta(N)
  1. Q4b from CSE 373 19au MT (Solution)
  2. Q4a from CS 61B 17sp MT2 (Solution)
  3. Q8a from CS 61B 18sp MT2 (Solution)
  4. Q4a from CS 61BL 18su MT2 (Solution)