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.
Step by Step Answer:
public class BinaryTree private int elements private boolean isPresent private int cursor public Bin...View the full answer
Students also viewed these Computer science questions
-
In this project, you will design and implement a class called Towers, which is part of a program that lets a child play a game called Towers of Hanoi. The game consists of three pegs and a collection...
-
This project uses the Towers class from Chapter 3s Programming Project 12. For the project, write a recursive methodxtxhxat computes and prints a solution to the Towers of Hanoi game. The method...
-
Specify, design, and implement a class for complete binary trees using the array representation from Section 9.2. You should have only one method that adds a new node (since there is only one place...
-
Using the aggregate expenditures table below, answer the questions that follow. a. Compute the APC when income equals $2,300 and the APS when income equals $2,800. b. Compute the MPC and MPS. c. What...
-
Using a collection of sample data, we construct a frequency table with 10 classes and then construct the corresponding histogram. How is the histogram affected if the number of classes is doubled but...
-
What is the product of the solutions to the equation in Exercise 45? Data from Exercises 45 What is the sum of the solutions for the equation x 2 4x + 13 = 0?
-
Describe the role of the judge and jury in the trial process.
-
The chairman of the board of Hughes Corporation proposed that the board hire as controller a CPA who had been the manager of the team that conducted Hughes Corporations audit engagement. The chairman...
-
What measures are in place to monitor and evaluate the efficacy of strategic plans, enabling timely course corrections and adjustments in response to performance feedback and market developments ?
-
Digital Imaging (DI) produces photo printers for both the professional and consumer markets. The DI consumer division recently introduced two photo printers that provide color prints rivaling those...
-
This project deals with a simple kind of expression tree, in which there are two kinds of nodes: (a) Leaf nodes, which contain a real number as their element; (b) Non-leaf nodes, which contain either...
-
Revise the animal-guessing program from Figure 9.8 so that the initial knowledge tree is obtained by reading information from a file. Also, when the program ends, the knowledge tree at that point is...
-
Fill in the blanks with an appropriate word, phrase, or symbol(s). The conjunction p q is true only when both p and q are _______.
-
A car manufacturer announced that next year the price of a certain model car would increase by 4.5%. This year the price is $15,123. Find the increase and the new price
-
Show that if ST and g: TU are both surjective functions, then the composition gof: SU is surjective.
-
what is the assessment of home depots profitability over recent years
-
Ping Pong Manufacturing produces ping pong balls using a three minus step sequential process that includes moulding, colouring and finishing. When the balls and associated costs are transferred from...
-
Howard Corp. purchased an asset for $ 6 0 0 , 0 0 0 on Jan. 1 . The estimated salvage value is $ 4 0 , 0 0 0 , and the estimated useful life is 8 years. The double - declining balance method is used...
-
Assume in Problem 36 that Jane receives the 50 shares of Osprey Corporation stock in consideration for the appreciated property and for the provision of accounting services in organizing the...
-
When an electric field is applied to a shallow bath of vegetable oil, why do tiny bits of thread floating in the oil align with the field like compasses in a magnetic field?
-
Calculate the time necessary to perform a multiply using the approach described in the text (31 adders stacked vertically) if an integer is 8 bits wide and an adder takes 4 time units.
-
Calculate the time necessary to perform a multiply using the approach given in Figure 3.7 if an integer is 8 bits wide and an adder takes 4 time units. Figure 3.7 Mplier31 Mcand Mplier30 Mcand...
-
As discussed in the text, one possible performance enhancement is to do a shift and add instead of an actual multiplication. Since 9 6, for example, can be written (2 2 2 + 1) 6, we can calculate...
-
Watch the recorded interview of Ms . Veronica Trammell, Executive Director of Learning Technology at KSU. The interview focused on service management and service operation. Share your thoughts in...
-
develop a detailed event plan following the assigned event type and theme with the following information: Event objectives based on the assigned event type and theme Two sets of varying food &...
-
Provide a detailed simulation performance results for Walmart inc. based on 5 year performance review.
Study smarter with the SolutionInn App