Question: Specify, design, and implement a class for binary trees where the nodes elements are stored in an array, similar to the way that a complete

Specify, design, and implement a class for binary trees where the node’s elements are stored in an array, similar to the way that a complete binary tree is usually stored. However, these binary trees do not need to be complete. Instead, you should have a second private instance variable that is an array of boolean values called isPresent. The isPresent array indicates which nodes actually exist in the tree. For example, if the tree has a root node, then isPresent[0] is true. If the root has a left child, then isPresent[1] is true. If the root has a right child, then isPresent[2] is true, and so on.

The class should have methods to create the first node and to move a cursor around the tree. After the first node, new nodes may be added only as children of the cursor.

Step by Step Solution

3.41 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class BinaryTree private int elements private boolean isPresent private int cursor public Bin... View full answer

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 Data Structures and Other Objects Using Java Questions!