CSE 2320 - Assignments

Not Graded Practice for Assignment 2

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.


Practice Question 1

(This is Problem 2.2 from the textbook).

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.


Practice Question 2

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.


Practice Question 3

(This is Problem 2.3 from the textbook).

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.


Practice Question 4

(This is Problem 2.4 from the textbook).

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.


Practice Question 5

(This is Problem 2.5 from the textbook).

For what values of N is 10N log N > 2N2?


Practice Question 6

(This is Problem 2.6 from the textbook).

For what values of N is N3/2 between N(log N)2/2 and 2N(log N)2?


Practice Question 7

(This is Problem 2.8 from the textbook).

What is the smallest value of N for which log10 log10 N > 8?


Practice Question 8

(This is a modification of Problem 2.12 from the textbook).

Write a function, in your favorite programming language, that efficiently computes an approximation of HN, using the built-in log function of that language.


Practice Question 9

(This is Problem 2.20 from the textbook).

Prove that O(1) is the same as O(2).


Practice Question 10

(This is Problem 2.24 from the textbook).

Show that NM = O(αN) for any integer M >= 1 and any constant α > 1.


(Challenge) Practice Question 11

(This is Problem 2.25 from the textbook).

Prove that:

N / (N + O(1)) = 1 + O(1/N)


(Challenge) Practice Question 12

(This is Problem 2.27 from the textbook).

Suppose that log(k!) = N. Give an approximate formula that expresses k as a function of N


(Challenge) Practice Question 13

(This is Problem 2.44 from the textbook).

Solve the recurrence:

CN = (2 + 1 / (log N))CN/2,       for N >= 2, with C1 = 1.


(Challenge) Practice Question 14

(This is Problem 2.48 from the textbook).

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.


(Challenge) Practice Question 15

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.