CS 341, Spring Fall 2024

Programming Assignment # 3

Due: midnightWed 11/13/2024

 

Hierarchical structures: Write a java collections class that implements a 2-3-4 Search Tree.

 

On this tree class implement the following methods:

 

            To construct the tree from the contents of an input file

 

            To find if a value exists in the tree

 

            To return the height of the tree.

 

Method to output the values from this tree such that the values are output sorted.

 

            Method to insert a value into the 2-3-4 tree.

           

Write a Java application that reads an input file (234tree.dat) that describes a flattened tree and constructs the corresponding tree. The format of the flattened tree is as below:

 

Values at the node followed by lines that indicate the values at each of its children.

A blank line followed by description of another node.

 

Example:        Content of file                                    Description

 

                        20 50                           root node has 20 and 50 (has 3 children)

                        5 12                             first node has 5 12;

                        35 42 45                      second has 35 42 45

                        61                                third has 61

 

                        5 12                             node has 5 12 (three children)

                        2 4                               first has 2 4

                        6 11                             second has 6 11

                        14 17 18                      third has 14 17 18

 

                        35 42 45                      node has 35 42 45 (four children)

            25 32                           first has 25 32

            37 39 41                      second has 37 39 41

            43                                third has 43

            46 48                           fourth has 46 48

 

            61                                node has 61 (two children)

            55 57                           first has 55 57

            63 65                           second has 53 65

 

Note that the content of the file is conformant to 2-3-4 tree. You can create your own file based on the above format for testing. Your program should be able to construct a tree based on the content of the file, not just for the above example.

 

Export your project to your folder in class storage by the due date.

 

Questions and Collaboration: Any questions about the problem – email, inquire in class, or discuss with instructor. You are free to discuss the problem-solving part. Do not view or use code developed by others.