




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Name:___________________
Short Problems; Show all work to receive full-credit; 10 points each
Suppose an algorithm has exponential running time T (n) = 2n, where n is the problem size. Assuming that on the average a computer can execute a step of the algorithm in 10−^8 seconds, what is the largest problem size that can be solved in 100 seconds? You may leave your answer unsimplified.
Assuming the same computer in problem 1), how long will it take to run an algorithm with running time T (n) = 10n on an input of size 1000?
Give as good a big-O estimate as possible for the running time of the following program, with input n. Hint: integrate to approximate the resulting sum.
sum = 0 for(i = 1; i ≤ n; i + +) for(j = i; j 6 = 0; j=j/2) sum + + return sum
For nodes A, C, J, and H in the tree below, give their parents, children, siblings, depth, and height.
Give a big-O estimate of the function f (x) = x log(x^4 +1) + x(log x)^2. Your answer should be of the form O(g(x)) where g has the smallest order possible. Explain.
Long Problems: Show all work, and explain when necessary; 20 points each
A node of a binary tree is called full if and only if it has two children. Use mathematical induction to prove that the number of full nodes plus one of a binary tree equals the number of leaves of the tree.
The average number of full nodes (see problem 1 for a definition) on a binary search tree is given by the recurrence relation
f (N ) =
N∑ − 1
i=
(f (i) + f (N − i − 1)).
Use mathematical induction to prove that f (N ) = N^ − 3 2 is a solution for this recurrence relation.