Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to use Binary Trees to do this Program. Write a complete program, using the node representation of Binary Trees (the nodes can

imageimageimageimage

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import javautil class Node String data Node left right public NodeString item data item left right n... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

Determine the area of the triangle. 5 cm| E7 cm

Answered: 1 week ago

Question

Write pseudocode to compute DFT -1 n in (n lg n) time.

Answered: 1 week ago