// University of Iowa // Homework 3, Problem 2 // by: Justin C. Miller // Prof: Sriram 1. What sort of a function do you see? If you're talking about the entire program... O(n^2) or quadratic 1.20| 1.10| * 1.00| .90| * .80| .70| * .60| * .50| .40| * .30| * .20| * .10| * .00| * * |-------------------------------------------------- 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 2. Rate of growth of this function? Same thing as above... If you're talking about the entire program... O(n^2) or quadratic because you do n enqueues and enqueue is O(n) 3. How to modify this program to make enqueue O(1)? Three ways to do this... 1.) make it a doubly linked list, then you have instant access to the front & back 2.) keep track of 2 pointers, a front & a back, then dequeue from the front, and enqueue onto the back, then both enqueue & dequeue would become O(1) 3.) make it so the dequeue grabs from the back and the enqueue pushes onto the front (this of course would make dequeue go from O(1) to O(n), which is probably a bad thing)