CS367 Homework 4
Lecture 1, Spring 2018
Due by 11:59 pm on Friday, April 6, 2018 (not accepted late)

Questions

Homework assignments must be done individually. Collaboration on homework assignments is not allowed.

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:

      55  44   33   22   11   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   77   99   55   22   33

    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:

      55  44   33   22   11   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   77   99   55   22   33
  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:

      6   44   20   27   73   34   10   22   89

    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:

        3 20  7 24 41 15 32 56 72

    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

Please include your name at the top your file.

For this assignment you have a variety of options for creating and submitting your answers.

You may draw your trees and arrays in an ordinary text file, using characters to form boxes and arrows (just as was done in the early days of computing). You may use a figure drawing tool as found in Word, Powerpoint, and numerous other programs. Then submit the figures as an ordinary pdf file. You may also draw your trees and arrays by hand on a standard-sized sheet of paper; clearly print your name at the top of your paper. Then scan or photograph your answer sheet into a pdf or jpg file. Name your answer file Homework4 with the appropriate file extension, e.g., Homework4.pdf or Homwwork4.txt.

Electronically submit your work to the Homework 4 tab on Canvas.

Last Updated: 1/11/2018     © 2014-18 Beck Hasti and Charles Fischer