Implement a yes/no guessing game called 20 Questions using a binary tree. At the beginning of each

Question:

Implement a yes/no guessing game called 20 Questions using a binary tree. At the beginning of each round of the game, the human player thinks of an object. The computer tries to guess the object by asking a series of no more than 20 yes-or-no questions. Eventually the computer guesses what the object is. If this guess is correct, the computer wins; if not, the human player wins.

The computer keeps track of a binary tree with nodes representing questions and answers. A “question” node contains a left “yes” subtree and a right “no” subtree. An “answer” node is a leaf. This tree can be traversed to ask the human player questions until it reaches a leaf node, at which point the computer asks whether that answer is the
correct one.

Initially the computer is not very intelligent, but it grows more intelligent with each game. If the computer’s answer guess is incorrect, the player must give it a new question to help it in future games. This is similar to the game found at the web site http://animalgame.com/. You should write methods to construct a tree, play a game, and save/load the tree’s state from a file.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: