Use the binary search tree code to do the following:

  • Put the names that follow into a file
  • Read the file and insert the names into the binary search tree
  • After all nodes have been read, print the tree using inorder.
  • Print the height of the tree
  • Remove Yate and Nancy
  • Print the height of the tree
  • Print the tree using inorder

Names:

George
Bill
Nancy
Antonio
Sally
Mike
Cathy
Zac
Nolan
Kody
Xena
Yate

Have a menu that will do:

  • Add name
  • remove name
  • Write file
  • Read file
  • Show height
  • Print tree inorder
  • Quit

Have the user be able to drive the steps.

Have an option 7 that would write the contents of the tree to a file, inorder, then read it back in to balance the tree. Remember that the algorithm works mainly with a full tree. A full tree has the number of nodes of 2h - 1. Try and get the tree to have that number. Then write and read the tree (count the dummy nodes). Remove the dummy nodes.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.