Binary Trees Lab 20 Questions
Submission
o Submit all code and other materials in a single zip file to the appropriate assignment folder on Kodiak.
Goal: Build a system that learns to play a "20 Questions"-like game.
Files
• tree.py - (Do not modify.) Base class for all trees. . binary_tree.py - (Do not modify.) Base class for all binary trees. • linked_binary_tree.py - (Do not modify.) Implementation of a binary tree using linked nodes. • main.py - (Do not modify) Calls play_game() in twenty.py to play the game. • twenty.py - (Modify) Implements the 20 questions game. • training.txt - (Modify) A trace of you training your system. gametree.dat - (Modify) The saved tree generated by your training. Introduction Prior to doing any design, make sure to thoroughly review each of the modules which were distributed with this lab. If anything is unclear about these dasses, ask! Your textbook describes these classes in further detail in Sections 8.1-8.3. Problem You may have seen online games that purport to be "psychic," with the ability to correctly guess any item or character that you may be thinking of by asking yes/no questions of the player. Your goal is to write a program that can play this game, in part by learning about a universe of your choice as it plays by asking yes/no questions. For example, your program might learn about animals by having the following dialogue with its user. (For readability, user responses are shown here in red. The responses also use capital letters, which is not a requirement for this assignment.) Think of an animal, and I will guess it. Does it have legs? yes Is it a cat? yes I win! Continue? yes Think of an animal, and I will guess it. Does it have legs? no Is it a snake? yes I win! Continue? yes Think of an animal, and I will guess it. Does it have legs? no Is it a snake? no I give up. What is it? earthworm Please type a question whose answer is yes for earthworm and no for enake: Does it live underground? Continue? yes Think of an animal, and I will guess it. Does it have legs? no Does it live underground? no Is it a snake? no I give up. What is it? fish Please type a question whose answer is yes for fish and no for snake: Does it live in water? Continue? no The program begins with minimal knowledge about animals: It knows that cats have legs and snakes do not. When the program incorrectly guesses "snake" the next time, it asks for the answer and also asks for a way to distinguish between snakes and earthworms. The program builds a binary tree of questions and animals. A "yes" response to a question is stored in the question's left child; a "no" response to a question is stored in the question's right child Task Extend make a child class of) the Linkedinaryfree class to create a data structure that supports this game. Make use of the protected methods in LinkedBinaryTree to modify the tree structure. You may name your class anything you wish, though your module must be named twenty.py. Additionally, you must have a play_game () function in the module (not your class) that allows the user to play when it is called. We want to avoid having to retrain the system from scratch every time we play the game. So we'll save and load the tree to and from a file. BinaryTree (which you are extending) already has methods for saving and loading the tree: save_tree() and load_tree(). The examples below demonstrate how to use them. Save a tree to gametree.dat mytree.save_tres('gametree.dat') Load a tree from gametree.dat mytree = BinaryTree.load_tree 'gametree.dat's These methods read and write binary files. So you will not be able to read them in a plain text editor When the game first begins, ask if they want to load a file, and if so ask for the filename. Would you like to load a game? yes What file should I load? gametree.dat When the game ends, ask if the user would like to save the file, and if so ask for the filename to save the tree to. Would you like to save the game? yes What Eile should I save to (I will overwrite it)? gametree. dat import linked_binary_tree # Define your class here. Give it a better name than A, # and make sure it extends LinkedBinary Tree. class A: def play_game): # Game logic here. # Feel free to create other methods, modules and classes. | Provide a session log of you training your system from scratch. Just copy and paste your interaction with your program.

Answers

Answer 1

The binary tree is implemented using the following class to represent nodes in the tree. Please read the comment to learn how it is used.

/**

* A class to represent nodes in the binary tree that

* holds the questions.  There are actually two types

* of nodes, depending on the value of the finalAnswer

* field.  

*

* If finalAnswer is true, then the node represents a guess

* by the computer, and the question field should contain only

* the name of the item that is being guessed, such as "a dog"

* or "a tube worm".   In this case, the node is a leaf, and the

* yes and no fields are ignored.

*

* If finalAnswer is false, then the node represents a

* question that the computer will ask.  The question field

* contains the complete question, such as "Is it a mammal?"

* or "Are you thinking of a mammal?".  The yes and no fields

* point to the subtrees that correspond to the answers "yes"

* and "no" to the question.

*/

private static class TreeNode {

boolean finalAnswer;

String question;

TreeNode yes;

TreeNode no;

}

Note that this class uses yes and no as pointers to the left and right subtrees. Also, note that only nodes in which finalAnswer is false have subtrees; nodes in which finalAnswer is true are leaves on the tree.

To learn more about TREE NODES please click on below link.

https://brainly.com/question/30224516

#SPJ4


Related Questions

a person who creates a computer virus is called

Answers

Answer:

A person who creates computer virus is known as hacker.

Sans serif typeface is a good choice for
a. printed documents
b.document headings
c. document text
d. document content

Answers

Answer: A Sans-serif font is a good choice for headings and small text where clarity and readability are paramount. A Serif font is good to use on larger blocks of printed text like on a flyer.

Explanation:

In your own words, describe invention.

Answers

Answer:

An invention is an action of doing or creating something. Typically, a process of something.

Explanation:

Hopefully, it helps!

Answer:

Creating something new

Explanation: Invention is something that you originally create and don't copy from anyone else. The microwave was invented in 1945 that changed of how people used kitchen appliances, invention is kinda just another word for creativity (since it's the process of it!)

Hope this helps and make sure to thank me!

Explanation:

PLS HELP ASAP) Omar is using the web to do research on diabetes. he needs to ensure that all of the information he finds regarding medications, treatments, and diets are accurate. the first websites he finds has a lot of information about a diet plan to help diabetic live healthy lifestyle. Omar can't figure out who the author of the site is and he notices that matches the one described on the website. Which of these are red flags that he should continue doing more research elsewhere? choose the right answer

a. the content is biased towards a particular diet plan that the site is advertising

b. Omar cant find the author so there is no proof that the writer can be trusted to provide medical advice.

c. both A and B

d. none of the above. the website can be trusted.


Nikolas is doing research on U.S visas for a school project. he has found conflicting information on two sites. the first site is travel.state.gov and the other is traveldocs.com which site should Nikolas trust more? choose the answer

a. Travel.state.gov

b. Traveldocs.com

Answers

Not sure on the first question, but the second would be answer choice a: Travel.state.gov since a website with .gov at the end tend to be trustworthy sources

Answer: 1. C. both A and B.

2.  Travel.state.gov

Explanation: i took the test!

press _________ to toggle the selected range as bold​

Answers

Answer:

press the b that i in a dark shade that is bold

Write a definition in your own words for Raster Graphic. Do not copy and paste please.

Answers

Answer:

Raster Graphic is a bitmap. They are basically a grid of small pixels that make an image.

Shawn has connected his laptop to a projector and chosen to duplicate his screen to the projector. Which statement is true in this situation regarding the Presenter view?

It will be used by default.
It will not be used by default but can be selected.
It cannot be used.
It must be used.

Answers

Answer:

B. It will not be used by default but can be selected.

Explanation:

PowerPoint application can be defined as a software application or program designed and developed by Microsoft, to avail users the ability to create various slides containing textual and multimedia informations that can be used during a presentation.

Some of the features available on Microsoft PowerPoint are narrations, transition effects, custom slideshows, animation effects, formatting options etc.

Basically, the views that are available on the Microsoft PowerPoint application includes;

1. Slide Sorter.

2. Notes Page.

3. Reading Pane.

4. Presenter view.

Presenter view avails the user an ability to use two monitors to display his or her presentation. Thus, one of the monitors displays the notes-free presentation to your audience while the other monitor lets you view the presentation with notes that you have added to the slides, as well as the navigation and presentation tools.

In this scenario, Shawn has connected his laptop to a projector and chosen to duplicate his screen to the projector. Hence, the statement which is true in this situation regarding the Presenter view is that it will not be used by default but can be selected by the user.

PLEASE HELP ME! Sam was researching rocks and minerals. He thought the Web site looked unprofessional, so he looked for the author's information or credentials. He couldn't find any. Is this site reliable? A. Probably B. Probably not.

Answers

Answer:

B

Explanation:

If a site looks unprofessional and doesn't have any credentials, those are two signs that it's probably not very reliable.

the manager of a xyz organisation is preparing the organizational chart which feature of MS Excel /he will use to do so? also write the steps for this​

Answers

Answer:

Smart Art

Explanation:

The smart art feature in Microsoft excel allows for the creation of organizational chart on Microsoft excel. It readily allows for an hierarchical arrangement of an organization's personnel including the various departments on the system. The smartart allows the implementation of a graphical output which allows the display of an organization's personnel in order of hierarchy. To get started with smart art on excel, Clicking on the insert tab, the same are appears under illustrations. For an organizational chart, the Hierarchy smart art graphic type is selected and filled accordingly.

Help!!
What’s the inputs and outputs of a printer
And what’s the inputs and outputs of a digital assistant/ Alexa??

Answers

Answer:

Input of printer - text

Output of Printer - text printed on paper

Input & output of digital Alexa - Voice/sound

Explanation:

Input for a printer is the text data entered into any of the file formats that can be printed.

Output of a printer is the text printed on a piece of paper.

Input of a digital assistant is in the form of voice

Output of a digital assistant in the form of sound

Que ventajas podria traer el internet a la educacion artistica? Ayuda porfa telo pido porfavor

Answers

Answer:

"Informacion"

Explanation:

La internet puede traer las mismas ventajas para la educacion artistica que cualquier otra materia y eso es "Informacion". El arte tiene muchas tecnicas. Tambien hay muchos differentes estilos de arte. La internet tiene toda la informacion sobre los artistas mas famosos de las historia, incluyendo su arte, tecnicas, estilos, temas, historias, etc. Esta informacion es sumamente importante y util por que te enseña a utilizar todos los metodos ya creados y usarlos como herramientas para crear arte que representa el artista que sos.

How can identity theft be prevented?

Answers

Answer:

Identity theft can be prevented by using proper security measures

Explanation:

Identity theft can be prevented by using proper security measures such as stronger passwords and VPN. It can also be protected by making sure your system security is up to date.

Multiple Select
Which of the following statements about localization are true? Select 2 options.
The goal of localization is to create an application or site that looks and feels like it was created for a specific market.
Really the only issue in localization is translating the text into another language.
You should avoid slang and idioms, since they will not be understandable to many audiences.
It is a good idea to use lots of images, since they are easily understood by all cultures.
For consistency, it is a good idea to use dollars as a currency in all versions of an application

Answers

Answer:

A. The goal of localization is to create an application or site that looks and feels like it was created for a specific market.

B. Really the only issue in localization is translating the text into another language.

Explanation:

In Computer science, localization can be defined as the process of designing, developing and adaptation of computer software applications or websites for different languages and geographical regions with peculiar differences.

This ultimately implies that, the main purpose for localization of a product such as a website or software application is to ensure they are specialized and specifically suited for a linguistic or geographical region.

The following statements about localization are true;

I. The goal of localization is to create an application or site that looks and feels like it was created for a specific market.

II. Really the only issue in localization is translating the text into another language.

Answer:

C. You should avoid slang and idioms since they will not be understandable to many audiences.

A. The goal of localization is to create an application or site that looks and feels like it was created for a specific market.

are the answers

Explanation:

What type of device is a keyboard?

Input
Memory
Output
Storage

Answers

Answer:

a keyboard is an input device

it's an input

Explanation:

There are three different types of peripherals: Input, used to interact with, or send data to the computer (mouse, keyboards, etc.) Output, which provides output to the user from the computer (monitors, printers, etc.) Storage, which stores data processed by the computer (hard drives, flash drives, etc.)

Write a loop that will take in 5 numbers from the user and output the average. Round your answer to two decimal places.
Sample Run:

Enter a number: 2
Enter a number: 7
Enter a number: 11
Enter a number: 4
Enter a number: 5
The average is 5.8

Hurry please!! will mark brainliest!!

Answers

I’m gonna do it in the form of a pseudocode.

Pseudocode 1: Number_Average
Declare sum, num, num_count, average
START
sum = 0
num_count = 0
average = 0
Display “Enter a number”
Read num
Display “Enter a number”
Read num
Display “Enter a number”
Read num
Display “Enter a number”
Read num
Display “Enter a number”
Read num
While(count = 5)
DO
num_count = 0+1
sum = 0+1
average = sum/5
ENDWHILE
STOP

If you would like to give another user permissions on your mailbox or to particular folders within your mailbox, which role should you configure?

Assignee
Client
Delegate
Manager

Answers

Answer:

I think it's B, Delegate

Explanation:

Cause the other options didn't seem to fit as the answer.

I really don't know though.

A delegate is someone who has been granted permission by another user to access. The correct answer would be an option (C).

What is a mailbox?

A computer-simulated mailbox that stores email messages. Mailboxes are saved on a disc as a message file or a message database.

A delegate is someone who has been granted permission by another user to access and manage their mailbox, including sending and responding to email messages on their behalf.

When you grant delegate access to another person, you are giving them the ability to access specific folders within your mailbox and perform specific actions, such as reading, sending, and deleting email messages.

Assignee, client, and manager are not terms typically used in the context of delegate access in email systems.

Thus, the correct answer would be option (C).

Learn more about the mailbox here:

https://brainly.com/question/28430685

#SPJ6

what will the following program display in the console

Answers

what nnnnnnnnnnnnn nnnnn
It will display the numbers 0 through 3 on each separate line I think

What does this mean

Answers

Answer:

"Y YUR Y YUB I CUR YY 4 ME"

Explanation:

thats what i read lol, i dont know the meaning though

Question #6
Multiple Choice
What tag is used to contain information about a web page, such as the title and related pages?

O
O

Answers

Answer:   b; head

Explanation:

Answer: <head>

Explanation: EDGE '23

Accenture began its own Cloud journey in 2015, after our internal IT organization recognized the significant advantages to be gained in leveraging Cloud capabilities at scale. Today, which percentage of Accenture's infrastructure and processes are in the Cloud?

Answers

Answer: 95%

Explanation:

Accenture began its own Cloud journey in 2015, and invested in about $3 billion to move to cloud. This has helped the company in timely delivery and achieving organizational goals.

Today, the percentage of Accenture's infrastructure and processes that are in the Cloud is about 95%. Its HR, sales, finance, legal system etc are all in cloud.

The percentage of Accenture's infrastructure and processes that are stored or located in the Cloud is: 95%.

A Cloud can be defined as the elastic leasing of pooled computer resources (physical hardware) over the Internet and through the use of virtualization.

Accenture is one of the world's largest management and technological consulting company that provide services such as:

Database managementConsultingStrategy planningOutsourcing

Basically, Accenture help business organizations in the implementation of data governance and management policies, in order to ensure the organization's data is trustworthy and reliable.

In 2015, Accenture started its own Cloud journey after recognizing the significant advantages it stand to gain or benefit in leveraging Cloud capabilities at a larger scale.

Consequently, the percentage of Accenture's infrastructure and processes that are stored or located in the Cloud is 95 percent.

Read more: https://brainly.com/question/23844088

What is block palette

Answers

The block palette is an area of the graphical user interface located between the stage, sprite pane and scripting area.

Which of the following allows you to copy
formatting of text from one part of your presentation
and apply it to text in another part of your
presentation?
Animation Painter
Animation
Format Painter
slide master
DONE

Answers

Answer:

format painter

Explanation:

3. Windows that are viewed as Web pages have
sections. **

Answers

Answer:

when the when the when the add the when are you is id god his gay for your top off jack dafe cafe read line green red whats the answer

Explanation:

Create a file name that to ensure the that the file is easy to find

Answers

Answer:

I always name mine something like HI

or YEET i dont know

why but it works

Explanation:

The File name would be : ABC!

A person who creates a computer virus is a (1)system analyst (2) techician(3) programmer​

Answers

Answer:

a person who creates a computer virus is a programmer

Answer: hacker

Explanation:

70s music or russian music

Answers

Explanation:

BB cgbfyhcthcfgvxdrgjyfddg

Don’t listen to any

What is Exploring technology?

Answers

Answer:

Investigating Technology is a thorough, activity based, course that acquaints understudies with innovation and its effect on society.

Explanation:

Answer: Exploring Technology is a comprehensive, action-based, course that introduces students to technology and its impact on society.

Explanation: it on googIe....

Evaluate each condition as to whether it is true or not.
You can join the Army if you are over 17 and healthy. Have you met those requirements if you are 16 and healthy?
You can earn a scholarship if you have an ACT over 30 or you are valedictorian of your high school. Have you eamed a scholarship if you have an ACT
of 34 but are not the valedictorian?

Answers

Answer:

For the first one you have not met those requirements because you are still 16, for the second one you have met those requirements because you can either have a score over 30 (which you have 34) or be a valedictorian

Explanation:

Above

A writing guide in making a project correctly.

a.project proposal
b.project plan
c.project format
d.project template ​

Answers

Answer:

b

Explanation:

B Project plan hope this helps

What is the 3 common keys used to access the BIOS.​

Answers

Answer:

To access your BIOS, you'll need to press a key during the boot-up process. This key is often displayed during the boot process with a message “Press F2 to access BIOS”, “Press <DEL> to enter setup”, or something similar. Common keys you may need to press include Delete, F1, F2, and Escape.

Other Questions
In year 0, Longworth Partnership purchased a machine for $57,500 to use in its business. In year 3, Longworth sold the machine for $38,800. Between the date of the purchase and the date of the sale, Longworth depreciated the machine by $27,300a. What are the amount and character of the gain or loss Longworth will recognize on the sale?DescriptionAmountTotal Gain/(Loss) RecognizedCharacter of Recognized Gain/(Loss):Ordinary Gain/(Loss)1231 gain/(loss)b. What are the amount and character of the gain or loss Longworth will recognize on the sale if the sale proceeds are increased to $70,000?DescriptionAmountTotal Gain/(Loss) RecognizedCharacter of Recognized Gain/(Loss):Ordinary Gain/(Loss)1231 gain/(loss)c. What are the amount and character of the gain or loss Longworth will recognize on the sale if the sale proceeds are decreased to $21,600?DescriptionAmountTotal Gain/(Loss) RecognizedCharacter of Recognized Gain/(Loss):Ordinary Gain/(Loss)1231 gain/(loss) There is scientific evidence that supports the theory that many organisms share a common ancestor. The table lists some evidence. InformationScientific EvidenceThe bone structure of forelimbs in humans and bats are similar in shape and function. The DNA sequences for the production of hemoglobin, a type of molecule in blood, within humans and chimpanzees are almost identical. QuestionWhich statement can provide additional scientific evidence to support how some organisms share a common ancestor?Answer options with 4 optionsA. Searching for many fossils of the same type of species located on two continents. B. Displaying the differences between species that are unable to fly and those that can fly. C. Recording the length of time organisms require to reproduce and successfully raise offspring. D. Showing the similarities of anatomical structures in early stages of development of organisms modern geology uses two methods of dating, namely: suppose the population of tasmanian devils (in thousands) is modeled by p(t)=20(1 3e0.05t) where t is in years. what is the populations carrying capacity? A client is in labor is receiving magnesium sulfate to treat hypertension of pregnancy. How should this drug be administered?A. As a loading dose of 4g in normal saline solution, followed by a continuous infusion of 2-3g/hourB. As a loading doge of 2g in sterile water, followed by a continuous infusion of 2-3g/hourC.As a loading dose of 4g in dextrose 5% solution in water, followed by a continuous infusion of 2-3g/hourD.As a loading dose of 4g in dextrose 5% in water, followed by a continuous infusion of 2-4grams/hour the channel with the highest cost per exposure is usually display advertisingT/F Current assets, fixed assets, and liabilities are all part of an organization's:a) Capital expendituresb) Balance sheetc) Income statementd) Expense budgete) Statement of cash flow Type or upload your short ancient Roman news article (5-7 sentences). Your article should include as many of yourspeling words as possible. Remember to underline your spelling words when you use them. aristotle, plato, and socrates all thought and lectured while performing which type of exercise Female ClientAge: 38Weight: 75 kgHeight: 175 cm% Body fat: 30%Activity level: SedentaryLean body mass: 50 kgAnita wants to feel good for her 20th high school reunion in several months. Her goal is to lower her body fat to 18%. You recommend that she: Assume each spinner is divided into equal-sized sections. If you spin each spinner once, what is the probability of spinning a 1 and a B? a 27-year-old patient has a total cholesterol of 206 mg/dl and an ldl of 110. which of the following conclusions can be drawn? where is the string experiencing maximum oscillation amplitude (anti-node location) and where is the string experiencing minimum, or zero, oscillation amplitude (node location)? what evidence is consistent with the idea that east asian cultures tend to exhibit more collectivist thinking than american culture? (3 choices are correct) You have a cylinder with a 4" stroke and a piston diameter of. 80 inches. What would the approximate output force be if you applied 100 PSI? Write a mechanism for the reactions involved in the xanthoproteic test with a tyrosine residue. 12. all of the following can unnecessarily increase clearance time except: For a standard normal random variable z, p(z a vitamin d-deficiency syndrome characterized by bone deformities in children is called: find the area of the surface obtained by rotating the curve y=x36 12x,12x1,y=x36 12x,12x1, about the xx-axis