Specify, design, and implement a class for binary trees where the nodes elements are stored in an

Question:

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: