CS 111 Avila University Introduction To Data Structures Binary Tree Lab Report I uploaded the instruction and the class CS 111 >> Introduction to Data Stru

CS 111 Avila University Introduction To Data Structures Binary Tree Lab Report I uploaded the instruction and the class CS 111 >> Introduction to Data Structures
Spring 2020
Lab Assignment 10
I NSTRUCTIONS
P ROBLEM 1
Using the given class MyBinaryTree.java (which includes the BinaryNode class), complete MyBinaryTree.java.
It should contain the following attributes:

public BinaryNode root – The top-most node in the tree – in this implementation, the first node added to the tree.
As well as the following constructors/methods:


MyBinaryTree(): constructor – Initializes root with a null value.
insert(int newValue): void – Inserts a BinaryNode containing the value newValue into the appropriate location in the
binary tree. If a node with this value already exists, a node is not added.

search(int searchValue): boolean – Searches the tree for a node containing the value listed, returning true if found and
false otherwise.

orderedPrint(BinaryNode pos): void – Prints out the contents of each BinaryNode in natural order (lowest to highest for
integers). The node pos determines the current position of the pointer in the tree. You will want to use recursive calls
of orderedPrint() for this method.
When finished, you can use the main method located inside MyPriorityQueue.java to test your methods.
rev. April 22 – 1 / 1

Purchase answer to see full
attachment

Submit a Comment