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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started