Implement a new method for the BTNode from Figure 9.10. The new method creates a Java Vector
Question:
Implement a new method for the BTNode from Figure 9.10. The new method creates a Java Vector that contains the data from all the nodes in a tree, as specified in Figure 9.15. Details about the Java Vector class are provided in Appendix D, although the only Vector method you’ll use is addElement.
Also specify and implement similar methods that use in-order and post-order traversals instead of a pre-order traversal. Which of your three new methods creates a Vector with the entries sorted from smallest to largest?
Transcribed Image Text:
FIGURE 9.10 Specification and Implementation of the Generic Binary Tree Node Class Generic Class BTNode * public class BTNode
FIGURE 9.10 Specification and Implementation of the Generic Binary Tree Node Class Generic Class BTNode * public class BTNode from the package edu.colorado.nodes A BTNode provides a node for a binary tree with a reference to an E object as the data in each node. Limitations: Beyond Int. MAX_VALUE elements, treeSize is wrong. Specification Constructor for the BTNode public BTNode(E initialData, BTNode initiallLeft, BTNode initialRight) Initialize a node with specified initial data and links to children. Note that a reference to a child may be null, which indicates that there is no child. Parameters: initialData - the initial data of this new node initialleft and initialRight- references to the children of this new node Postcondition: This new node contains the specified data and links to its children. getData-getLeft-getRight public E getData( ) public BTNode getLeft( ) public BTNode getRight( ) These are accessor methods to obtain this node's data or a reference to one of the children. Any of these objects may be null. A null reference to a child indicates that the child does not exist. getLeftmostData public E getleftmostData( ) Accessor method to get the data from the leftmost node of the tree below this node. Returns: The data from the deepest node that can be reached from this node following left links. getRightmostData public E getRightmostData( ) Accessor method to get the data from the rightmost node of the tree below this node. Returns: The data from the deepest node that can be reached from this node following right links.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 58% (12 reviews)
import javautilVector public class BTNode public int data public BTNode left right public ...View the full answer
Answered By
FELIX NYAMBWOGI
I have been tutoring for over 5 years, both in person and online. I have experience tutoring a wide range of subjects, including math, science, English, and history. I have also worked with students of all ages, from elementary school to high school.
In addition, I have received training in effective tutoring strategies and techniques, such as active listening, questioning, and feedback. I am also proficient in using online tutoring platforms, such as Zoom and Google Classroom, to effectively deliver virtual lessons.
Overall, my hands-on experience and proficiency as a tutor has allowed me to effectively support and guide students in achieving their academic goals.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
You have recently been hired by International Products Inc.s (IPI) internal audit department and are sitting in your office planning for your upcoming meeting with the head of internal audit. It is...
-
A group of Northeastern University researchers developed a new method for ranking the total driving performance of golfers on the Professional Golf Association (PGA) tour (The Sport Journal Winter...
-
The Extron Oil Company is considering making a bid for a shale oil development contract to be awarded by the federal government. The company has decided to bid $110 million. The company estimates...
-
2. A magazine printer is considering taking on a new weekly publication. The company's financial officer has researched and determined costs and a committee of upper management personnel are deciding...
-
The 300 numbers selected in the Lotto 6/49 (not the bonus numbers). a. Construct a histogram. b. Describe the general shape of the distribution, such as bell-shaped, uniform, or skewed
-
Journal 3 Police operations + community relations https://www.ojp.gov/pdffiles1/nij/grants/205003.pdf https://www.ojp.gov/pdffiles1/nij/117447.pdf...
-
Annual US craft beer production. Refer to the annual US craft beer production time series, Exercise 14.7 (p. 14-10). a. Calculate the exponentially smoothed series for US beer production for the...
-
Ehrlich Co. began business on January 2, 20Y8. Salaries were paid to employees on the last day of each month, and social security tax, Medicare tax, and federal income tax were withheld in the...
-
Rose is considering a project which requires new equipment at a cost of $170,000. The equipment has a 3-year tax life and will be depreciated by the MACRS method. When the project closes down at the...
-
In each case, determine the problem and fix the errors. After you correct the errors, save each file using the same filename preceded with Fix. For example, DebugOne1.java will become...
-
This project requires that you know how to determine the actual time taken for a method to execute. Write a test program for the bag class from Section 9.5. The program should allow the user to...
-
Binary search trees have their best performance when they are balanced, which means that at each node n, the size of the left subtree of n is within one of the size of the right subtree of n. Write a...
-
For states $|\alphaangle$ and $|\betaangle$, define time-reversed states by $|\tilde{\alpha}angle=\Theta|\alphaangle$ and $|\tilde{\beta}angle=\Theta|\betaangle$. Show that the overlap of the...
-
The air in an automobile tire with a volume of \(0.015 \mathrm{~m}^{3}\) is at \(30^{\circ} \mathrm{C}\) and \(140 \mathrm{kPa}\) (gage). Determine the amount of air that must be added to raise the...
-
Convex Productions has just received a contract to film a commercial video that will air during a major sporting event in North America, and then be available on-demand through banner advertisements...
-
The following data (and annotations) for March 2016 are for the work in process account of the first of Olympus Companys four departments used in manufacturing its nly product. Assuming that Olympus...
-
If relative volatility can be assumed constant over the change in concentration for each fraction, Eq. \((9-13)\) can be adapted to the collection of fractions from a simple binary batch...
-
(a) Design a PI controller for Problem 8.6-4(b). (b) Design a PD controller for Problem 8.6-4(c). (c) Use the results of parts (a) and (b) to repeat Problem 8.6-4(d). Problem 8.6-4(b) (c) (d) (b)...
-
Multiplication and division. Simplify. 4(5x 6) 3(2 5x)
-
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?
-
Write down the binary bit pattern to represent -1.5625 10 -1 assuming a format similar to that employed by the DEC PDP-8 (the left most 12 bits are the exponent stored as a twos complement number,...
-
IEEE 754-2008 contains a half precision that is only 16 bits wide. The left most bit is still the sign bit, the exponent is 5 bits wide and has a bias of 15, and the mantissa is 10 bits long. A...
-
The Hewlett-Packard 2114, 2115, and 2116 used a format with the left most 16 bits being the fraction stored in twos complement format, followed by another 16-bit fi eld which had the left most 8 bits...
-
Read the following and then answer the questions below:September 12: A Brisbane business offers by letter to sell 500 tyres to a New Zealand company. The Brisbane company does not specify a method of...
-
Fred returns home from work one day to discover his house surrounded by police. His wife is being held hostage and threatened by her captor. Fred pleads with the police to rescue her and offers...
-
Would like you to revisit one of these. Consideration must be clear and measurable.if you can't measure it then how can you show it has / has not been done?How can you sue someone for breach of...
Study smarter with the SolutionInn App