CS 311 Fall 2008 > Midterm Exam Review Problems, Part 3 |
This is the third of three sets of review problems for the midterm exam. For all three sets, see the class web page, or the following links:
Review problems are given below. Answers are in the Answers section of this document. Do not turn these in.
Explain the thinking that (probably) underlies this quote.The fundamental law of computer science: As machines become more powerful, the efficiency of algorithms grows more important, not less.
But Quicksort is actually quadratic-time, not log-linear time.
What is wrong with the above reasoning?
In each part, indicate whether the give statement will compile. You may assume that all variables have been properly initialized.class Foo { public: void nonConFunc(); void conFunc() const; }; Foo nonConObj; const Foo conObj; Foo * nonConPtr; const Foo * conPtr;
Insertion Sort is also used as a finishing step in an optimized Quicksort. We write a recursive Quicksort so that it does nothing when given a small list. Calling such a function on a large list results in a nearly sorted list, which we can then finish sorting using insertion sort. This procedure is also used in Introsort, which is based on Quicksort.
For Ω, we replace “at most” with “at least”: we say g(n) is &Omega(f(n)) if g(n) is at least some constant multiple of f(n), for sufficiently large values of n.
Finally, g(n) is &Theta(f(n)) if it is both O(f(n)) and &Omega(f(n)), that is, if it lies between two constant multiples of f(n), for sufficiently large values of n.
Note: A third advantage of Merge Sort, which did not come up in the first half of the semester, is that its structure makes it work much better than Introsort with data accessed over a slow connection, for example data stored in a disk file.
CS 311 Fall 2008: Midterm Exam Review Problems, Part 3 / Updated: 17 Oct 2008 / Glenn G. Chappell / ffggc@uaf.edu |
|