cos423: Theory of Algorithms | handout #18 |
Michael Goldwasser | |
Princeton University | Tuesday, March 31, 1998 |
Homework #6: | Randomized Algorithms and Hashing |
Due Date: | Tuesday, April 7, 1998 (5:00pm) |
Assume that every object x has two associated values, key[x] and priority[x]. We define a new data structure called a treap, which is a binary tree with objects stored at internal nodes, satisfying the following two properties. (we assume that keys are distinct, and that priorities are distinct)
We would like to maintain a treap dynamically through a sequence of calls to Insert, Delete, and Search, as defined below. In the following three parts, we will ask you how to implement each of these operations while maintaining the properties of a valid treap. For each operation, you should briefly justify the correctness of your implementation as well as the bound on its running time. In describing your implementations, you may feel free to refer to descriptions of basic operations on binary trees as described in Chapter 13 of the text.
Up until now, we have assumed that an object given to Insert arrives with both a key and a priority. If we want to maintain a set of objects for which only the key is defined, we are free to choose any values we want for priorities, and the above routines will be correct. For the remainder of the problem, we assume that when an object x with key[x] is inserted, we set the priority of that object uniformly at random to a real number in the range [0,1]. (The probability that two different objects choose the identical priority is equivalently zero.)
Suppose that we have a hash table with n slots, with collisions resolved by chaining, and suppose that n keys are inserted into the table. Each key is equally likely to be hashed to each slot. Let M be the maximum number of keys in any slot after all the keys have been inserted. Your mission is to prove an upper bound on E[M], the expected value of M.
Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds.