Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 9 (10 points) In this task you should implement a binary tree for arbitrary data types. First create a new project Task 9-GenericBinTree. Exercise

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Task 9 (10 points) In this task you should implement a binary tree for arbitrary data types. First create a new project "Task 9-GenericBinTree. Exercise 9.1- BTreeNode and BTree (3 points) Copy the BTreeNode and BTree classes from the subdirectories of https://github.com/dbermbach/progiwinf-examples-ws1819 /src/de/tuberlin/mcc/proglwinf/datastructures). These classes implement a binary tree for the data type int. Rearrange both classes so that in the tree any type of data can be stored. Use Java Generics for that and that Interface ComparablecT>. Exercise 9.2- Traversal (2 points) Add the enum Traversal to the project with the values PREORDER, INORDER and POSTORDER added. Then add an enum to the BTree class parameterized constructor and store the passed value in an attribute traversal. Finally, override the BTree class's toString method: Je according to the value with which the traversal attribute is assigned, the toString)Method output the tree in the appropriate order. Exercise 9.3 - ChemElement (2 points) Create the ChemElement class with the attributes name (String) and density (double), which implements the Comparable interface. Also add one Add the appropriate constructor, override the class's tostring0 method, and implement the compareTo( ) method so that the element density compared to each other (lighter elements are smaller). Exercise 9.4- BTreeTest (3 points) Finally, write a class called BTreeTest that contains your implementation tests. To do this, first create a BTree for strings and place it at least 10 different values in it. Then test the output of the tree with your implementation of the tostring0 method. Then put one Additional BTree for the ChemElement class, also fill this with at least 10 different objects and test the output(s). Task 9.5-In the lab Answer your tutor's questions about your submission of task 9. 101112131415161718192021222324publicclassBTreeNode{publicintvalue;publicBTreeNodeleft;publicBTreeNoderight;**QparamvaluepublicBTreeNode(intvalue){super();this.value=value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started