This is a set of practice questions. Feel free to work on these questions, and to ask questions if you face any difficulties in coming up with answers. While collaboration with others on the graded homework is strictly prohibited, you are free to work on these practice questions together with other people.
Since they are practice questions, you do not have to, and should not, submit answers to these questions on Blackboard. These questions will not be considered in any way towards your course grade. At the same time, based on the instructor's experience, individuals spending substantial and systematic effort in answering these practice questions by themselves tend to significantly improve their overall class performance.
How long does it take to count to 1 billion (ignoring overflow)? Determine the amount of time it takes the program
int i, j, k, count = 0; for (i = 0; i < N; i++) for (j = 0; j < N; j++) for (k = 0; k < N; k++) count++;to complete in your programming environment, for N = 10, 100, and 1000. If your compiler has optimization features that are supposed to make programs more efficient, check whether or not they do so for this program.
Measure the running time of an implementation of Selection Sort (you can use the one posted on the course website) for N = 100, 1000, 10000, 100000. Specify: the implementation that you used, the inputs that you used, the machine on which you made the measurements.
Develop an expression of the form c1N + c2N2 + c3N3 that accurately describes the running time of your program from textbook Exercise 2.2 (practice question 1 on this web page). Compare the times predicted by this expression with actual times, for N = 10, 100, and 1000.
Develop an expression that accurately describes the running time of Program 1.1 (the quick-union version of Union-Find) in terms of M and N.
For what values of N is 10N log N > 2N2?
For what values of N is N3/2 between N(log N)2/2 and 2N(log N)2?
What is the smallest value of N for which log10 log10 N > 8?
Write a function, in your favorite programming language, that efficiently computes an approximation of HN, using the built-in log function of that language.
Prove that O(1) is the same as O(2).
Show that NM = O(αN) for any integer M >= 1 and any constant α > 1.
Prove that:
N / (N + O(1)) = 1 + O(1/N)
Suppose that log(k!) = N. Give an approximate formula that expresses k as a function of N
Solve the recurrence:
CN = (2 + 1 / (log N))CN/2, for N >= 2, with C1 = 1.
Estimate the probability that at least one of M random 10-digit numbers matches one of a set of N given values, for M = 10, 100, and 1000 and N = 103, 104, 105, and 106.
Prove that the running time of find is O(log N), for the weighted-union version of the Union-Find algorithm.
Back to the list of assignments.