Skip to main content
Lesson 36 - Deletion from a Binary Tree
ZIPPDF (letter)
Lesson MenuPrevious
  
L.A.36.1 - BSTree (Part 3) page 5 of 5

Assignment:

  1. Copy the methods presented in Handout, H.A.36.1, Deletion from a Binary Tree. However, you are required to solve the two-child case as a mirror image of the solution described in Section B.7. of the student outline O.A.36.1. Change the deleteTargetNode method to deal with the two-child case as follows:

    1. Position marker to access the node with the smallest value in the right subtree. This is the leftmost node in the right subtree.

    2. Copy the contents of the left child of marker and set it as the current value.

    3. Delete the smallest value from the left subtree. Reattach the left subtree to maintain an ordered tree.


  2. Test your code and solve the following sequence of run output steps:

    1. Load the file from disk (file20.txt).

    2. Print the tree.

    3. Print the number of nodes in the tree.

    4. Search for Id values specified by your instructor. Print out the Id and Inv response in column form.

    5. Delete the Id values specified by your instructor.

    6. Print the tree again.

    7. Print the number of nodes in the tree.



Instructions:

  1. Turn in your source code for the entire program and the run output described above.


Lesson MenuPrevious
Contact
 ©ICT 2003, All Rights Reserved.