


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!



Question 1a. (10 points) Show the AVL trees (plural) that result from inserting the keys 186, 039, 991, 336, 778, 066, 564, 154, 538, and 645 into an initially empty tree. Question 1b. (5 points) Show the result of deleting the key 186 from the tree in part a. Question 2. (10 points) Show that any n-node binary tree can be converted into any other using at most 2n rotations.
Question 3. (20 points) Find the approximate growth rates of the function f for each of the following recursively defined functions. In each case, assume that f(1) = 1. Don't simply guess; show your work. a. f(n) = f(n-1) + n- 1 b. f(n) = f(n/2) + 1 c. f(n) = 2f(n/2) + 1 d. f(n) = 2f(n/2) + n/ Question 4. (1 5 points) Interviewing at a data mining company, a nameless job applicant once faced the following question. Suppose that you have a very large file containing a random series of lowercase English words, one per line. You have been ordered to count how many times each word appears in the file and display the results (in no particular order) to your pointy-haired boss. You have as much RAM as necessary to do the job, but you may only read through the file ONCE. Describe an algorithm to perform this task Explain what data structure(s) you will need and why your choice is the best possible.
Question 7. (15 points) When designing heap sort, there are two natural ways to build a heap of n items starting from n unrelated items: