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
-
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...
-
You have a problem and need a printed copy of Code Section 1033. Go to the U.S. House of Representatives' website (www.house.gov) and search for the "United States Code." The Internal Revenue Code is...
-
Find the domain of the vector-valued function. r(t) = 4 - t 2 i + t 2 j - 6tk
-
Consider the following cash flow profile, and assume MARR is 10 percent/year. a. What does Descartes' rule of signs tell us about the IRR(s) of this project? b. What does Norstrom's criterion tell us...
-
Premiums Presented below are three independent situations. 1. Mar-quart Stamp Company records stamp service revenue and provides for the cost of redemptions in the year stamps are sold to licensees....
-
1. We define the product of operators by composition. That is, AB|4) = A(B|4)). Show that, for the two-level atom, the evolution operator satisfies U(t) U(ts)U(s).
-
Give examples from the last month or so where you participated in a positive-sum, a zero-sum, and a negative-sum power relation. Describe what motivated you to participate in a negative-sum or a...
-
New-Project Analysis The president of the company you work for has asked you to evaluate the proposed acquisition of a new chromatograph for the firm's R&D department. The equipment's basic price is...
-
You are returning a client's phone call and cannot reach them. What are some tips to consider? Answer the following questions: How long should the message be max? What information should you include?...
-
What does a "factor" mean? a. Find all of the factors of 50 with factor pairs. b. Find the prime factorization of 50 and explain where all of the factors of 50 are in the prime factorization. c....
-
To complete your last year in business school and then go through law school, you will need $25,000 per year for 4 years, starting next year (that is, you will need to withdraw the first $25,000 one...
-
Walkrun Inc. is unlevered and has a value of $700 billion. An otherwise identical but levered firm finances 40% of its capital structure with debt at a 6% interest rate. No growth is expected. Assume...
-
Two identical bars, each with mass m, are connected by a smooth joint at C. At A and B are small, easily movable wheels, which roll on a horizontal track. The horizontal constant force P B gives the...
-
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...
-
Write a program in \(\mathrm{R}\) that generates a sample \(X_{1}, \ldots, X_{n}\) from a specified distribution \(F\), computes the empirical distribution function of \(X_{1}, \ldots, X_{n}\),...
-
Let \(\left\{X_{n}ight\}_{n=1}^{\infty}\) be a sequence of random variables such that \(X_{n}\) has a UNI\(\operatorname{FORM}\left\{0, n^{-1}, 2 n^{-2}, \ldots, 1ight\}\) distribution for all \(n...
-
Write a program in \(\mathrm{R}\) that generates a sample from a population with distribution function \[F(x)= \begin{cases}0 & x
Study smarter with the SolutionInn App