hw8 - y ]= x . (Hint: do this problem in 3 steps. First...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMPS 101 Summer 2009 Homework Assignment 8 (practice only, do not turn in) 1. (1 Point) 12.2-1 Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the 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, 266, 382, 381, 278, 363. e. 935, 278, 347, 621, 299, 392, 358, 363. Note: Some of the topics represented by the following problems my not be covered by end of business Tuesday 8/11/09. If that is the case, those topics will not appear on the final exam. 2. (1 Point) 12.2-6 Let x be a node in a Binary Search Tree, all of whose keys are distinct. Suppose that x has no right child, and that x has a successor, call it y . Prove that y is the lowest ancestor of x whose left child is also an ancestor of x . Note that x is considered to be it’s own ancestor, so it is possible that left[
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y ]= x . (Hint: do this problem in 3 steps. First show that y must be an ancestor of x by eliminating the possibility that it is either a descendent of x or a cousin of x ; second, show the same thing for left[ y ]; third, show by contradiction that there is no ancestor of x which is lower than y , and which has the same properties. All steps boil down to a careful application of the BST properties.) 3. (1 Point) Insert the following keys (in order) into an initially empty Binary Search Tree, and draw the BST structure that results: 26, 41, 47, 17, 14, 30, 10, 38, 28, 21, 19, 12, 16, 39, 23, 20, 15, 7, 35, 3. Determine an assignment of colors Red and Black to the nodes in this tree so as to satisfy the Red-Black Tree properties. 4. (1 Point) 13.1-5 Show that the longest simple path from a node x in a red-black tree to a descendant leaf has length at most twice that of the shortest simple path from node x to a descendant leaf....
View Full Document

Ask a homework question - tutors are online