CS367 Homework 6
| ||
AnnouncementsCheck here periodically.
| ||
QuestionsQuestion 1:Assume that Red Black trees are implemented using a BinaryTreenode class that includes the following fields and methods: // fields private T data; private BinaryTreenode<T> left; private BinaryTreenode<T> right; private String color; // methods public T getData() { return data; } public <Treenode<T> getLeft() { return left; } public <Treenode<T> getRight() { return right; } public String getColor(){ return color; } Write the blackProperty method whose header is given below. public boolean blackProperty(Treenode<T> n) The method should return true if the tree satisfies the black property, and false otherwise. You may want to make use of a helper method Question 2:All parts of this question refer to standard binary search trees. The next question will deal with red-black trees, but for this question assume you are using simple binary search trees with no extra balancing logic. Part A: Show the binary search tree that results from inserting the following sequence of integers into a tree that is initially empty: Part B: Show the binary search tree that results from inserting the following sequence of integers into a tree that is initially empty: Part C: Show the binary search tree that results from deleting 66 from the tree in part B using the in-order predecessor. Part D: Show the binary search tree that results from deleting 33 from the tree in part B using the in-order successor. Question 3:All parts of this question refer to red-black tree. If you are creating a text-file containing your solution, indicate red nodes by using square brackets around the value (e.g., [44] ) and indicate black nodes by not using any brackets around the value (e.g., 44 ). If you are creating your solution by hand on a piece of paper, indicate red nodes by drawing a square around the value and indicate black nodes by drawing a circle around the value. Part A: Show the red-black tree that results from inserting the following sequence of integers into a tree that is initially empty: Part B: Show the red-black tree that results from inserting the following sequence of integers into a tree that is initially empty: | ||
Handing inPlease include your name at the top your file. Put your answers to the questions into one file named Homework6 with the appropriate file extension, e.g., Homework6.pdf (see File Format for acceptable file formats). Electronically submit your work to the Homework 6 Dropbox on Learn@UW. | ||
Last Updated: 7/23/2014 © 2014 Beck Hasti |