Tree Project

0 comments

Write a program that allows the user to enter numbers and build a Binary Search Tree. The code should perform the following operations:

  1. Input data. Your program must read numbers from a file. File name and location is: c:tempinput.txt. File consists of positive numbers and at the end, it contains -1. -1 means the end of input data. Once a -1 is reached, the program no longer reads in data and will build the tree using the positive numbers it read.
  2. Display TREE data. This option will display the following items ALL AT ONCE:
    1. Display Tree GRAPHICALLY. This option displays the tree in a “tree like” shape showing parent nodes, children nodes and the connections between the nodes
    2. Display tree in LNR
    3. Display tree in NLR
    4. Display tree in LRN
  3. ADD Number. Read 1 value from the user, then enter that value into the tree.
  4. REMOVE Number. Remove a value from the tree IF IT EXISTS. If it doesn’t exist, do not delete anything.

This is a sample of the input file:

10

15

20

33

-1

Source:

This is lecture Video:

In this video, the professor explain how to display the tree in one function (5 lines of code). Check it out. Code already shared under comment section in video.

In this video, the professor demonstrate some GUI examples that might inspire you when you work on the TREE Homework

Here is another video showing more innovative ways to solve the problem

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}