Vous êtes sur la page 1sur 1

1.

For the set of keys {1, 4, 5, 10, 16, 17, 21}, draw binary search trees of height 2, 3, 4, 5 and 6. 2. Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for number 363. Which of the following sequences could not be the sequence of nodes examined? a. 2, 252, 401, 398, 330, 344, 397, 363. b. 924, 220, 911, 244, 898, 258, 362, 363. c. 925, 202, 911, 240, 912, 245, 363. d. 2, 399, 387, 219, 382, 381, 278, 363. e. 935, 278, 347, 621, 299, 392, 358, 363. 3. A double-ended queue (deque) is a linear list for which for which insertions and deletions can occur at either end. Show how to represent a deque in a one - dimensional array and write algorithms that insert and delete at either end. 4. Consider a hash table of size m =1000 and a corresponding hash function h(k)=floor(m(k A mod 1)) for A = (5 1)/2. Compute the locations to which keys 61, 62, 63, 64 and 65 are mapped. 5. Show the red-black trees that result after successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially empty red-black tree. 6. From the red-black trees formed in question 5, show the red-black trees that result from the successful deletion of the keys in the order 8,12, 19, 31, 38, 41.

Vous aimerez peut-être aussi