Question: Exercise 1 Implementation of a Simple BinaryTreeNode ADT Goal: to implement a BinaryTreeNode ADT and test the operations of the ADT. A backbone of the

Exercise 1 Implementation of a Simple BinaryTreeNode ADT

Goal: to implement a BinaryTreeNode ADT and test the operations of the ADT. A backbone of the BinaryTreeNode.java is provided on moodle under Lab 5. Your first task is to fill in the methods in the class. Remember to test each of the operations in a test application. Note that we dont make an interface for this BinaryTreeNode ADT in this lab, because next week we will create a Tree ADT which uses this BinaryTreeNode internally, by then we will create an interface for a Tree. After your BinaryTreeNode ADT works correctly, created a binary tree as shown in the figure

Exercise 1 Implementation of a Simple BinaryTreeNode ADT Goal: to implement a

BinaryTreeNode.java ( please edit this code to let it work) /** * BinaryTreeNode represents a node in a binary tree with a left and * right child. * * @author Java Foundations * @version 4.0 */ public class BinaryTreeNode { protected T element; protected BinaryTreeNode left, right; /** * Creates a new tree node with the specified data. */ public BinaryTreeNode(T obj) { // students complete this method } /** * Returns the number of non-null children of this node. */ public int numChildren() { // students complete this method return -1; } /** * Return the element at this node. */ public T getElement() { // students complete this method T temp = null; return temp; } /** * Return the right child of this node. */ public BinaryTreeNode getRight() { // students complete this method BinaryTreeNode temp = null; return temp; } /** * Sets the right child of this node. */ public void setRight(BinaryTreeNode node) { // students complete this method } /** * Return the left child of this node. */ public BinaryTreeNode getLeft() { // students complete this method BinaryTreeNode temp = null; return temp; } /** * Sets the left child of this node. */ public void setLeft(BinaryTreeNode node) { // students complete this method } } 

4 10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!