Design a class called TreeNode (the class java file should be called TreeNode.java) that encodes a binary tree node with integral values, with the following (exact) fields and methods/constructors:
Fields and Methods | Description | |
Fields | Data | The integral data in the node |
Left | Link to the left subtree | |
Right | Link to the right subtree | |
Methods | TreeNode | A constructor with no parameters that initialized with fields |
Design a class called TreeNodeWrapper (the class java file should be called TreeNodeWrapper.java) that encodes a wrapper for the TreeNode class, with the following (exact) fields and methods/constructors:
Fields and Methods | Description | |
Fields | TreeNodeRef | A reference to a tree node |
Left | Link to the left subtree | |
Right | Link to the right subtree | |
Methods | get | Return the TreeNode from the wrapper |
set | Add a TreeNode to the wrapper |
Design a class called BinarySearchTree (the class java file should be called BinarySearchTree.java) that encodes an extended version of a binry search tree, with the following (exact) fields and methods/constructors:
Fields and Methods | Description | |
Fields | Root | The root node of the tree (a TreeNode object) |
Methods | BinarySearchTree | A constructor with no parameters that initializes the fields |
Insert | Insert a value (given by the parameter) into a new node in the tree. Use the TreeNodeWrapper to manage the TreeNode | |
Fetch | Fetch a value (given by the parameter) from the tree | |
Delete | Delete a value (given by the parameter) from the tree | |
Update | Update a value (given by the first parameter) from the list to a new value (given by the second parameter) | |
FindNode | Find a value in the tree (given by the parameter) | |
TraverseLNR | Traverse the tree in LNR order | |
TraverseLRN | Traverse the tree in LRN order | |
TraverseNLR | Traverse the tree in NLR order | |
TraverseNRL | Traverse the tree in NRL order | |
TraverseRLN | Traverse the tree in RLN order | |
TraverseRNL | Traverse the tree in RNL order |
Design a class called Graph (the class java file should be called Graph.java) that implements an LQHashed data structure, with the following (exact) fields and methods/onstructors:
Fields and Methods | Description | |
Fields | Vertex | The one-dimensional array of vertices |
Edge | The two-dimensional array of edges. The value in each cell is the edge weighting. | |
MaxVertices | The maximum number of vertices | |
NumberVertices | The number of vertices in the graph | |
Methods | Graph | A constructor with no parameters that initializes the fields and create the arrays |
TraverseDepthFirst | Traverse the graph in depth-first order | |
TraverseBreadthFirst | Traverse the graph in breadth-first order | |
Sort | Collect the vertices in an array and sort them using the fastest sorting algorithm and output them | |
MinimumSpanningTree | Determine the minimum spanning tree and output it (traverse in NLR order) | |
ShortestPath | Determine the shortest path between every 2 vertices in the graph and output them |
After you design the BinarySearchTree, and Graph. Please design a program/project/driver class which is called Main, that will create an object of both classes, and the functionality of both classes. Akso, add the BinarySearchTree and Graph to the Main project, and add the code to the project/driver class.