CS367 Homework 7
Lecs 1 & 2, Spring 2012
Due by 5:00 pm on Monday, April 16 (not accepted late)

Announcements

Check here periodically.

4/10/2012  Homework assigned. Questions about this assignment should be sent to cs367-1@cs.wisc.edu. Note that you may turn your solution in either in a text-file or on a sheet of paper. See the Handing in section for more details.

Questions

What do I need to answer?

  1. 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:

      44  33   22   11   55   66   77   88   99

    Part B: Show the binary search tree that results from inserting the following sequence of integers into a tree that is initially empty:

      66   44   88   11   33   99   22   77   55

    Part C: Show the binary search tree that results from deleting 44 from the tree in part B using the in-order predecessor.

    Part D: Show the binary search tree that results from deleting 66 from the tree in part B using the in-order successor.


  2. 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:

      44  33   22   11   55   66   77   88   99

    Part B: Show the red-black tree that results from inserting the following sequence of integers into a tree that is initially empty:

      66   44   88   11   33   99   22   77   55
  3. Part A: Assume that a priority queue is implemented using a max heap. Show the contents of the max heap array that results from enqueuing (inserting) the following sequence of integer priorities into a heap that is initially empty:

      5   43   19   26   72   33   9   21   88

    Assume the array begins with 10 elements. Show your final answer in the form of an array, not as a binary tree, leaving any unused array slots blank.

    Part B: Assume that a priority queue is implemented using a min heap and the following shows the contents of the array, with slot 0 going unused:

        4 21  8 25 42 16 33 57 73

    Show the contents of the min heap array after three dequeue (removeMin) operations are done. Show your final answer in the form of an array, not as a binary tree, leaving any unused array slots blank.

Handing in

What should be handed in?

For this assignment you have two options for creating and submitting your answers:

  1. "draw" your trees and arrays in a plain-text (i.e., not ".doc") file, named H7.txt, and electronically submit it to your In "handin", OR
  2. draw your trees and arrays by hand on a standard-sized sheet of paper, clearly print your name and CS login at the top of your paper, and turn in your paper. You may turn in your paper in-class on Thursday, April 12, drop it off in person during Beck Hasti's office hours, or drop it off in Beck Hasti's mailbox on the 5th floor of the CS building. All submissions must be received by 5 pm on Monday, April 16.
Last Updated: 4/10/2012     © 2008-2012 CS367 Instructors