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: 63% (11 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
-
Most modern computing in organizations is based on clientserver models. Explain why this tends to be the case. Give an example of clientserver computing that you are familiar with and explain the...
-
Scores for the California Peace Officer Standards and Training test are normally distributed, with a mean of 50 and a standard deviation of 10. An agency will only hire applicants with scores in the...
-
For several years, Xtreme Co.s sales have been on a cash only basis. On January 1, 2011, however, Xtreme Co. began offering credit on terms of n/30. The amount of the adjusting entry to record the...
-
What areas of developmental psychology research are emerging and How can a researcher grow and learn more to make a difference in the area of developmental psychology
-
Allie has bought a new apple orchard. The orchard has a single file of trees, numbered from 1 to N. Each tree has a certail number of ripe apples. Allie has a rule she wants to follow. She wants to...
-
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...
-
Is it possible for the average total cost curve to decline if the marginal cost curve is rising? Explain your answer.
-
Discuss the changes that would be necessary if more than one digit is stored per node in the LargeInt class.
-
Read the code segment and fill in blank #27. 1. predLoc 2. location 3. location->next 4. listData 5. answer not shown 4 Class Unsorted Type { public: //all the prototypes go here. private: int...
-
Write a member function PrintReverse that prints the elements on a list in reverse order. For instance, for the list X Y Z, list.PrintReverse() would output Z Y X. The list is implemented as a...
-
In each plastic container of Pez candy, the colors are stored in random order. Your little brother likes only the yellow ones, so he painstakingly takes out all the candies, one by one, eats the...
-
True or False? O(N) is called linear time.
-
Dorothy acquired a 100% interest in two passive activities: Activity A in January 2011 and Activity B in 2012. Through 2014, Activity A was profitable, but it produced losses of $200,000 in 2015 and...
-
For the next several days, take notes on your listening performance during at least a half-dozen situations in class, during social activities, and at work, if applicable. Referring to the traits of...
-
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...
-
Marea's Cakes sells its cakes for $30 each. Ingredients cost Marea on average $10 per cake and she pays her baker $10 per cake. For the upcoming year, Marea's fixed costs will be $50,000 and she...
-
The statement of cash flow consists of three main activities, as follows: Operating Investing Financing Each section provides the reader with details on where the cash came from and where the cash...
-
How would i calculate the desired ROI per unit based on this information: $65Per Unit Direct Materials $48.00Per Unit Direct Labour $16.00Per Unit Variable Manufacturing Overhead $12.00Per Unit...
Study smarter with the SolutionInn App