Purpose: Make a form of a binary search tree called a decision tree. The decision tree...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Purpose: Make a form of a binary search tree called a decision tree. The decision tree stores questions and answers to them so that a user can be asked the questions, see if the answers to the questions are correct, and add new questions and answers in the event certain answers are found to be incorrect. The program starts by inviting the user to think of an animal and to indicate when the user is ready to proceed. Immediately, the computer guesses that the animal is an elephant. Presumably this guess is incorrect, so the user tells the computer what animal the user was thinking of. The computer learns from its mistake by asking the user to teach it a yes/no question that it can use in the future, to tell the difference between the incorrectly guessed animal, and the correct one. It "remembers" this, and in its enthusiasm invites the user to start another cycle by thinking of another animal, and thus the process continues. After a while, the computer "learns" enough so that it can pretty much figure out any animal that any user might think of. This type of artificial intelligence program is called an expert system, a basic form of machine learning in which an expert "trains" the computer and the results are used by others as a diagnostic tool. Perform the following steps: 1. Use this class definition for the binary tree nodes: class BTNode { String text; BTNode yes; BTNode no; } With this class definition, BTNode objects are used to store either a yes/no question or an animal name. All the nodes at the leaves of the binary tree contain animal names, and their yes/no references are null, because they are endpoints of different lines of questioning. The tree "grows" when a leaf is reached, and the animal name in that node is incorrect. In this case, the node "splits" -- you add two new nodes, and connect them to the tree with the yes/no references of the node containing the incorrect animal name. Now, you replace the incorrect animal name in the text string object member with a question, and put animal names in the two new nodes. 2. Use this pseudo code outline to create your driver program (this lab only requires a driver program): main method() { // make a "root" reference to a BTNode. Name the reference root // set root to a newly created node; set its text member to "elephant", BTNode yes and no references to null // start a "while" loop that runs each cycle of the program // get input from the user -- invite the user to think of an animal which it will try to guess // await the user's response, and break out of the loop if the user declines // declare a reference "p" to traverse the tree, and initialize it to "root" // start a loop to traverse the binary tree // if p.yes is null... //...print p.text as the guessed animal // ask user if this is correct // if correct, brag that answer was found by your program and break from loop // ask user what animal the user was thinking of... //...store what the user replied in a string named A // ask what yes/no question differentiates p,text from A... //...store what the user replied in a string named Q // ask which response is correct for A -- yes or no... //...store what the user replied in a character variable named YesNo // create two new nodes, call the nodes Y and N // if the correct response for A is yes... // copy A into Y.text // copy p.text into N.text // else if the correct response is no... // copy A into N.text // copy p.text into Y.text // copy Q into p.text // set Y.yes, N.yes, Y.no, and N.no to null // set p.yes to Y and p.no to N // break from loop // else if p.yes is not null // print p.text as a question // ask for a yes/no reply... //...store in character Yes No // if "yes", set p to p.yes // else if "no", set p to p.no } 3. Run through at least 5 cycles to test the code and to train the program. Be sure to initialize the root node's yes and no references, as well as its animal "guess". Be sure to include matching open and close braces for your loops and if statements. This is a single driver program. The only class that is needed for the driver program to make the binary tree is the BTNode. You will not have to use any other ADT or class definition to make the driver program. Purpose: Make a form of a binary search tree called a decision tree. The decision tree stores questions and answers to them so that a user can be asked the questions, see if the answers to the questions are correct, and add new questions and answers in the event certain answers are found to be incorrect. The program starts by inviting the user to think of an animal and to indicate when the user is ready to proceed. Immediately, the computer guesses that the animal is an elephant. Presumably this guess is incorrect, so the user tells the computer what animal the user was thinking of. The computer learns from its mistake by asking the user to teach it a yes/no question that it can use in the future, to tell the difference between the incorrectly guessed animal, and the correct one. It "remembers" this, and in its enthusiasm invites the user to start another cycle by thinking of another animal, and thus the process continues. After a while, the computer "learns" enough so that it can pretty much figure out any animal that any user might think of. This type of artificial intelligence program is called an expert system, a basic form of machine learning in which an expert "trains" the computer and the results are used by others as a diagnostic tool. Perform the following steps: 1. Use this class definition for the binary tree nodes: class BTNode { String text; BTNode yes; BTNode no; } With this class definition, BTNode objects are used to store either a yes/no question or an animal name. All the nodes at the leaves of the binary tree contain animal names, and their yes/no references are null, because they are endpoints of different lines of questioning. The tree "grows" when a leaf is reached, and the animal name in that node is incorrect. In this case, the node "splits" -- you add two new nodes, and connect them to the tree with the yes/no references of the node containing the incorrect animal name. Now, you replace the incorrect animal name in the text string object member with a question, and put animal names in the two new nodes. 2. Use this pseudo code outline to create your driver program (this lab only requires a driver program): main method() { // make a "root" reference to a BTNode. Name the reference root // set root to a newly created node; set its text member to "elephant", BTNode yes and no references to null // start a "while" loop that runs each cycle of the program // get input from the user -- invite the user to think of an animal which it will try to guess // await the user's response, and break out of the loop if the user declines // declare a reference "p" to traverse the tree, and initialize it to "root" // start a loop to traverse the binary tree // if p.yes is null... //...print p.text as the guessed animal // ask user if this is correct // if correct, brag that answer was found by your program and break from loop // ask user what animal the user was thinking of... //...store what the user replied in a string named A // ask what yes/no question differentiates p,text from A... //...store what the user replied in a string named Q // ask which response is correct for A -- yes or no... //...store what the user replied in a character variable named YesNo // create two new nodes, call the nodes Y and N // if the correct response for A is yes... // copy A into Y.text // copy p.text into N.text // else if the correct response is no... // copy A into N.text // copy p.text into Y.text // copy Q into p.text // set Y.yes, N.yes, Y.no, and N.no to null // set p.yes to Y and p.no to N // break from loop // else if p.yes is not null // print p.text as a question // ask for a yes/no reply... //...store in character Yes No // if "yes", set p to p.yes // else if "no", set p to p.no } 3. Run through at least 5 cycles to test the code and to train the program. Be sure to initialize the root node's yes and no references, as well as its animal "guess". Be sure to include matching open and close braces for your loops and if statements. This is a single driver program. The only class that is needed for the driver program to make the binary tree is the BTNode. You will not have to use any other ADT or class definition to make the driver program.
Expert Answer:
Answer rating: 100% (QA)
Heres a simple Java program based on the provided pseudo code import javautilScanner class BTNode St... View the full answer
Related Book For
Spreadsheet Modeling & Decision Analysis A Practical Introduction to Management Science
ISBN: 978-0324656633
5th edition
Authors: Cliff T. Ragsdale
Posted Date:
Students also viewed these programming questions
-
E9-5 (Algo) Calculating Direct Materials and Direct Labor Variances [LO 9-3, 9-4] Suds & Cuts is a local pet grooming shop owned by Collin Bark. Collin has prepared the following standard cost card...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Googles ease of use and superior search results have propelled the search engine to its num- ber one status, ousting the early dominance of competitors such as WebCrawler and Infos- eek. Even later...
-
In Problems 65-72, summarize all pertinent information obtained by applying the graphing strategy, and sketch the graph of y=f(x). 66. 68. 70. 72. x2x6 f(x) 2x 1x +14 f(x)-_-x2-4 x3-5x2-6x 3x +2...
-
Why do light bulbs usually burn out just after they are switched on and not when they have been on for a while?
-
A student wanted to produce the greatest number of pinecones from 6 A1 trees, using the procedures from Experiment 2. Which plants and site should the A1 trees be combined with to achieve the desired...
-
The following information is taken from the annual report of The Coca-Cola Company: Using this information, calculate the accounts payable turnover ratio and the days payable period for 2015 and...
-
How much would you have to invest today to receive: a. $15,000 in 8 years at 10 percent? b. $20,000 in 12 years at 13 percent? c. $6,000 each year for 10 years at 9 percent? d. $50,000 each year for...
-
Lauren does not like the new individual incentives program in the compensation system because it means that she has to keep track of her employees' performance. This represents the disadvantage of...
-
REI sells snowboards. Assume the following information relates to REI's purchases of snowboards during September. During the same month, 100 snowboards were sold. REI uses a periodic inventory...
-
Discuss the benefits of considering customers' needs for the business and explain your perspectives of value added to the customer. Please bring an example of a business you are familiar with and...
-
You collect a soil core from the field under natural field conditions as would be present after a week of prolonged rainfall, and measure the following properties of the soil. Total Volume of the...
-
Ages of Passenger Cars The average age of passenger train cars is 19.4 years. If the distribution of ages is normal and 16% of the cars are older than 24.0 years, find the standard deviation. Round...
-
Image transcription text Refer to Figure below for the continuous cooling transformation and hardness vs weight % carbon diagrams below. For the composition of 0.8 % carbon, state the appropriate...
-
Is the use of dual dating still relevant today given the requirements of obtaining sufficient, appropriate evidence?
-
What journal entry should be made to record a $50 price reduction given to a dissatisfied customer who previously purchased merchandise on account? The customer kept the merchandise. 2. A company...
-
The reactant concentration in a second-order reaction was 0.490 mol L-1 after 120 s and 4.10x10- mol L- after 900 s. What is the rate constant for this reaction?
-
Suppose you are comparing just two means. Among the possible statistics you could use is the difference in means, the MAD, or the max min (the difference between the largest mean and the smallest...
-
Use the multiplicative seasonal technique for stationary data to model the data. Use Solver to determine the optimal values of and . a. What are the optimal values of and ? b. Prepare a line graph...
-
Bellows Lumber Yard, Inc. stocks standard length 25-foot boards, which it cuts to custom lengths to fill individual customer orders. An order has just come in for 5,000 7-foot boards, 1,200 9-foot...
-
The XYZ Company produces two products. The total profit achieved from these products is described by the following equation: Every 1,000 units of X1 requires one hour of time in the shipping...
-
Define committed costs and provide two examples of committed costs?
-
ABC Framing has been hired to frame a light commercial building. The project began on July 2 and was completed on August 9. The following is a list of accounting transactions associated with the...
-
When calculating a ratio with numbers from the balance sheet and income statement, why must you use the balance sheets from the beginning and end of the period covered by the income statement?
Study smarter with the SolutionInn App