Revise the animal-guessing program from Figure 9.8 so that the initial knowledge tree is obtained by reading
Question:
Revise the animal-guessing program from Figure 9.8 so that the initial knowledge tree is obtained by reading information from a file. Also, when the program ends, the knowledge tree at that point is written to the same file. You must carefully specify the format of the data in this file. The format should make it easy to do two things: (a) read the file and set the initial tree, and (b) write the knowledge tree to the file, using some kind of traversal.
Transcribed Image Text:
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode import java.util.Scanner; public class Animal private static Scanner stdin = new Scanner(System.in); public static void main(String[ ] args) { BTNode root; instruct( ); root = beginningTree( ); do play(root); while (query("Shall we play again?")); System.out.println("Thanks for teaching me a thing or two."); public static void instruct(O | The implementation of this method is omitted-write it yourself! public static void learn(BTNode current) I| The implementation of this method is Self-Test Exercise 9. public static void play(BTNode current) { while (!current.isLeaf( )) { if (query(current.getData( ))) current = current.getLeft(); else current = current.getRight(); } System.out.print ("My guess is " + current.getData( ) + ". "); if (!query("Am I right?")) learn(current); else System.out.printin("I knew it all along!");
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 83% (12 reviews)
To revise the animalguessing program from Figure 98 to read and write the knowledge tree fromto a fi...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
-
Design considerations for the bumper B on the train car of mass M require use of a nonlinear spring having the load-deflection characteristics shown in the graph. Select the proper value of K so that...
-
To review chapter content related to each set of exercises, refer to the indicated Learning Objective. Revising Messages: Clarity Break the following sentences into shorter ones; revise as necessary...
-
Consider the Malthusian growth model. Recall that upper-case variables denote aggregate variables, lower-case variables denote per worker (or per capita) variables, and denotes the future period. In...
-
At the beginning of the year, Plummer's Sports Center bought three used fitness machines from Advantage, Inc. The machines immediately were overhauled, installed, and started operating. The machines...
-
In an insurance study of motor vehicle accidents, fatal crashes are categorized according to time of day, with the results given in the accompanying table. a. Complete the circular bar chart and...
-
It is possible to program responses into computers that simulate human emotions. For example, when a computer taking on the role of a nurse hears a parent say, My child has diarrhea, it can respond,...
-
0.8365 Use the Standard Normal Table or technology to find the z-score that corresponds to the cumulative area or percentile. Table 4-Standard Normal Distribution Arca Z 0 Z .09 .08 .07 .06 .05 .04...
-
Bayville has built a new elementary school, increasing the towns total to four schoolsAddison, Beeks, Canfield, and Daley. Each has a capacity of 400 students. The school board wants to assign...
-
Why is the scientific method important in developmental psychology? 2. Come up with a basic research question in developmental psychology. 3. Come up with an applied research question in...
-
Allie has bought a new apple orchard. The orchard has a single file of trees, numbered from 1 to N. Each tree has a certail number of ripe apples. Allie has a rule she wants to follow. She wants to...
-
Specify, design, and implement a class for binary trees where the nodes elements are stored in an array, similar to the way that a complete binary tree is usually stored. However, these binary trees...
-
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...
-
The manager of Parker Design, Inc., prepared the companys balance sheet as of March 31, 2018, while the companys accountant was ill. The balance sheet contains numerous errors. In particular, the...
-
True or False? A header node is a placeholder node at the beginning of a list, which is used to simplify list processing.
-
Write a class based on class SortedType as an unbounded arraybased implementation. If the dynamically allocated array is full, create an array double the size and move the elements into it.
-
True or False? A doubly linked list has two pointers in each node.
-
Refer to the data set weather.csv. Can you conclude that the proportion of times the record maximum has occurred after 1945 is greater than the proportion of times the record minimum has occurred...
-
The queue is implemented as a class containing an array of items, a data member indicating the index of the last item put on the queue (rear), a data member indicating the index of the location...
-
A number of years ago, Lee acquired a 20% interest in the BlueSky Partnership for $60,000. The partnership was profitable through 2015, and Lee's amount at risk in the partnership interest was...
-
What kind of rays are X-rays?
-
Using a table similar to that shown in Figure 3.10, calculate 74 divided by 21 using the hardware described in Figure 3.8. You should show the contents of each register on each step. Assume both...
-
Using a table similar to that shown in Figure 3.10, calculate 74 divided by 21 using the hardware described in Figure 3.11. You should show the contents of each register on each step. Assume A and B...
-
What decimal number does the bit pattern 00C000000 represent if it is a floating point number? Use the IEEE 754 standard.
-
Explain why leasing is an option for a company expansion. include, what leasing is and how it will benefit the company in it's expanding efforts. Also, how is capital or operating leasing recorded on...
-
Discuss the following statement: " A head of state signs a treaty on behalf of his country in excess of authority of his country, such treaty shal be void for inconsistency with domestic law of the...
-
A company is looking at new equipment with an installed cost of $415,329. This cost will be depreciated straight-line to zero over the project's 5-year life, at the end of which the equipment can be...
Study smarter with the SolutionInn App