CS212 Exams
Spring 1999 - Final

Solution to Running Time Analysis

WARNING: You should seriously try to answer this question before looking at the solution -- it's just a good study skill. Also, some answers on this page may be more brief than you would want to put down in an actual exam. If you want any type of partial credit, you should write more than just the solution.


T(0) = O(1)
T(n) = T(n/2) + O(1)  if n>0 and even
T(n) = T(n-1) + O(1) if n>0 and odd

power runs in O(lg n) time.


Question

Return to CS 212 Final - Spring 1999