Question: Objective: Write a program which creates a binary search tree of different fruit from a file. The comparison is based on the fruits weight The

Objective:

Write a program which creates a binary search tree of different fruit from a file.

The comparison is based on the fruits weight

The file is tab delimited format goes as follows

o Fruit Type \t weight

The binary search tree needs to have the following methods

o insert: inserts a new fruit into the tree

o delete: deletes the fruit instance. Keep in mind that in order for a fruit to be equal it must have the same same type and weight.

o print pre-order traversal: Print the data. Next explore the left subtree. Finally right explore subtree.

o print in-order traversal: Explore the left subtree. Print the data. Finally explore the right subtree.

o print post-order traversal: Explore the left subtree. Then explore the right subtree. Finally print out the data.

Finally write a test file that demonstrates THE POWER OF TREES!!! FRUIT!!! By reading a shape file.

HINTS:

Creating a class for fruit makes this problem so much easier

Having a toString, compareTo, and an equals method would really be useful

Recursion is your friend.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!