You are to use Binary Trees to do this Program. Write a complete program, using the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are to use Binary Trees to do this Program. Write a complete program, using the node representation of Binary Trees (the nodes can be implemented using either an array or dynamic storage, your choice) to do the following The program will read in a set of data representing a family tree. It will implement this as a binary tree in Java and then it will answer a series of questions about the family tree. Here is an outline of what the program will do: First it will do whatever initializations are necessary. Then it will read in a set of data representing a family tree. The format of the data is described below. You should print the original data as it is read in. By hand you should draw the original family tree in it's usual form. The program will convert the data from a general to a binary tree (this can be done as you are reading the data in or using the algorithm to convert it afterwards). By hand you should then draw the binary tree representing the original tree. Next the program will answer a series of questions about the tree. Possible questions are: Next the program will answer a series of questions about the tree. Possible questions are: 1) Who is the father of p? 2) Who are all the sons of p? 3) Who are all the brothers of p? 4) Who is the oldest brother of p? 5) Who is the youngest brother of p? 6) Who is the oldest son of p? 7) Who is the youngest son of p? 8) Who are the uncles of p? 9) Who is the grandfather of p? Note: P can be any node in the tree including the root or a leaf. The first thing to do is to locate p in the tree. (you might want to store some information on the way down to p.) You should determine what the question is then answer each question in a separate method. Note the same question can be asked several times for a given tree, each time for a different node p. After you have answered a series of questions about this tree you should start the process all over again for a different family tree. Start the output for each tree on a new page and do at least 3 family trees worth of data. Data - the set of data for each tree will look like this (you can decide how to separate sets of data for different trees). A name up to 10 characters - this is the top node in the tree An integer n (possibly 0) representing the number of sons this node has Example Jones 3 (the root Jones has 3 sons) Bob 2 Dan 0 Brian 1 (these are the 3 sons of Jones) Richard 0 Jake 1 (these are the 2 sons of Bob) Michael 1 (the one son of Brian) Bill 0 (the one son of Jake) Deville 0 (the one son of Michael) Note: You can use a different format as long as you explain what you did You are to use Binary Trees to do this Program. Write a complete program, using the node representation of Binary Trees (the nodes can be implemented using either an array or dynamic storage, your choice) to do the following The program will read in a set of data representing a family tree. It will implement this as a binary tree in Java and then it will answer a series of questions about the family tree. Here is an outline of what the program will do: First it will do whatever initializations are necessary. Then it will read in a set of data representing a family tree. The format of the data is described below. You should print the original data as it is read in. By hand you should draw the original family tree in it's usual form. The program will convert the data from a general to a binary tree (this can be done as you are reading the data in or using the algorithm to convert it afterwards). By hand you should then draw the binary tree representing the original tree. Next the program will answer a series of questions about the tree. Possible questions are: Next the program will answer a series of questions about the tree. Possible questions are: 1) Who is the father of p? 2) Who are all the sons of p? 3) Who are all the brothers of p? 4) Who is the oldest brother of p? 5) Who is the youngest brother of p? 6) Who is the oldest son of p? 7) Who is the youngest son of p? 8) Who are the uncles of p? 9) Who is the grandfather of p? Note: P can be any node in the tree including the root or a leaf. The first thing to do is to locate p in the tree. (you might want to store some information on the way down to p.) You should determine what the question is then answer each question in a separate method. Note the same question can be asked several times for a given tree, each time for a different node p. After you have answered a series of questions about this tree you should start the process all over again for a different family tree. Start the output for each tree on a new page and do at least 3 family trees worth of data. Data - the set of data for each tree will look like this (you can decide how to separate sets of data for different trees). A name up to 10 characters - this is the top node in the tree An integer n (possibly 0) representing the number of sons this node has Example Jones 3 (the root Jones has 3 sons) Bob 2 Dan 0 Brian 1 (these are the 3 sons of Jones) Richard 0 Jake 1 (these are the 2 sons of Bob) Michael 1 (the one son of Brian) Bill 0 (the one son of Jake) Deville 0 (the one son of Michael) Note: You can use a different format as long as you explain what you did
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
All individuals in Canada have the responsibility to take meaningful actions towards truth and reconciliation. As business professionals, we take it a step further and talk about our responsibility...
-
Suppose that the Treasury decided to finance its deficit with mostly long-term funds. How could this decision affect the term structure of interest rates? If short-term and long-term markets are...
-
Label the major structures you can observe in figures 5.18 d, 5.23, 5.24 b, and 5.29 b. Fig 5.18 Fig 5.24 Fig 5.23 Fig 5.29
-
One study examined the personal values of 116 students studying mortuary science with the intention of becoming funeral directors (Shaw \& Duys, 2005). The students completed a well-established...
-
The unadjusted trial balance of La Mesa Laundry at August 31, 2016, the end of the fiscal year, follows: The data needed to determine year-end adjustments are as follows: a. Wages accrued but not...
-
A 7 by 14 piece of lumber is planed from a rough board to a final size of 6" 1 by 13". Find the dimensions x and y of the shape created with two such boards. x= (Type an integer, fraction, or mixed...
-
Steam systems are used to generate power, and provide heat energy. They are found in power plants, chemical plants, refineries, and here at the UofA, they provide both heat and power. In this...
-
A firm offers terms of 2/9, net 40. What effective annual interest rate does the firm earn when a customer does not take the discount? Without doing any calculations, explain what will happen to this...
-
Assume you work for Evraz plc, the coal and iron ore miner. What would be the costs of shortages in such a firm? Explain using examples.
-
A bank has recently installed a new embedded mobile phone payment system for rural communities. Describe the effect this is likely to have on the companys short-term financial management.
-
Explain why a company might use a risk-neutral valuation approach for valuing real options. Is this method appropriate for traditional NPV?
-
Explain what is meant by cash budgeting. Review the various ways a firm can finance a short-term cash deficit and the various financing policies to manage current assets.
-
Campbell, a single taxpayer, has $400,000 of profits from her general store that she operates as a sole proprietorship. She has $100,000 of employee wages, $40,000 of qualified property, and $500,000...
-
An Atomic Energy Commission nuclear facility was established in Hanford, Washington, in 1943. Over the years, a significant amount of strontium 90 and cesium 137 leaked into the Columbia River. In a...
-
What does the matrix used in the shortest-paths algorithms correspond to in regular matrix multiplication? 888 8 8 88
-
Argue that in a breadth-first search, the value u.d assigned to a vertex u is independent of the order in which the vertices appear in each adjacency list. Using Figure 22.3 as an example, show that...
-
Write pseudocode to compute DFT -1 n in (n lg n) time.
-
a. Suppose that General Hospital has a current ratio of 0.5. Which of the following actions would improve (increase) this ratio? Use cash to pay off current liabilities. Collect some of the current...
-
What is the role of internal control in an organization?
-
What are the elements and principles of the COSO framework?
Study smarter with the SolutionInn App