Homework 3: Running Times
Due: Friday, March 8, before 9:00 pm
Instructions: Your solutions to the following problems must be typed, converted to PDF, and submitted on Blackboard. It is okay to discuss concepts underlying the problems with other students, but all final solutions must be your own work.
All solutions must be typed, converted to PDF, and submitted on Blackboard. No other format is acceptable. Scans or photos of hand-written solutions will not be accepted.
In each of the five questions below, you are given a program fragment. Estimate the running time for each program fragment in terms of n. Assume that the value of n is determined elsewhere in the program. You should make your upper bound and lower bound as tight as you can. Upper bounds that are too big and lower bounds that are too small will receive deductions during grading.
For each question:
- State an upper bound on the running time of the program fragment using O( ) notation.
- Briefly justify your upper bound.
- State a lower bound on the running time of the program fragment using Ω( ) notation.
- Briefly justify your lower bound.
Note: Even in cases where the upper bound and lower bound are the same function, the justifications would be different. You are claiming that the code will run no slower than the upper bound and no faster than the lower bound.