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
-
Music-Is-Us, Inc., is a supplier of musical instruments for professional and amateur musicians. The companys accountants make adjusting entries monthly, and they make all closing entries annually....
-
Explain why employers should place disclaimers in employee handbooks.
-
On August 31, 2016, Bouquet Floral Supply had a $170,000 debit balance in Accounts Receivable and a $6,800 credit balance in Allowance for Bad Debts. During September, Bouquet made the following...
-
Write a one paragraph editorial on what your opinion is of using credit in life. Is credit a good thing/bad thing as you move through life?
-
Given a Q-point of IDQ = 3 mA and VGS = -3 V, determine IDSS if VP = -6 V.
-
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...
-
In Problems 7592, find each indicated derivative and simplify. f(w) = ) = (w + 1)2
-
Identify and post an example of public relations that you come across. Discuss three ways noted in the example that help to articulate a firm's value proposition to its audience.
-
Why Amazon is opening brick-and-mortar stores (or acquiring Whole Foods). Gathering support from this article indicate why.? Why is it that encouraging online customers to visit a store increased...
-
Why do you deem Reebok brand "inauthentic" Provide and explain at least 3 examples (pictures and videos are best!) that show its inauthenticity. Describe how this is inauthentic to the brand's story?
-
Discuss the benefits of using Influencers. Identify possible liabilities of using Influencers that may not always act in an ethical manner. Then identify one or more Influencers you wish to use for...
-
According to Blumenthal et al, most of the "new drugs aren't even new drugs. They are modified versions of existing medications to protect the patent life, and profits, of existing drugs. Group, why...
-
Why does 357(c) require the recognition of gain when liabilities assumed by a corporation exceed the adjusted basis of the assets transferred?
-
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...
-
1. How does marketing create value, and how do firms become more value driven? 2. Describe a firm's stakeholders and how they are impacted by conscious marketing.
-
Beginning inventory 100 units @ $8.00 = $ 800 Purchase # 1 200 units @ $6.00 = 1,200 Purchase # 2 100 units @ $12.00 = 1,200 Total 400 units $3,200 Ending inventory is 150 units. 1. What is cost of...
-
Sam's Ice Creams, a cottage country favourite in Northern Ontario, has launched a new range of ice creams branded as "Summer Flavours." To capitalize on the cottage and tourism season from May to...
Study smarter with the SolutionInn App