QuestionsGame
made up of QuestionNode
s. It is up to you to create the QuestionNode
, as well. It may help to think of a QuestionNode
like the nodes in a normal binary tree. In this case, QuestionNode
s keep track of a piece of data and have two pointers to other QuestionNode
s. This is so that the QuestionNode
can keep track of a question and then a pointer for the yes direction and a pointer for the no direction. When the game is played, the computer can ask a question by starting with the question stored in the root of the QuestionsGame
. Then, the user answers yes or no, and you can go deeper into the tree by following the appropriate yes or no pointer in that QuestionNode
. Then, you can repeat the process until you find a potential answer. If the answer is not what the user was thinking then you can add a new node to the QuestionsGame
. This node will have a new question in it (that the user provides) and it points to the object that the user was thinking of and the answer you guessed that was incorrect. If you are still having trouble understanding this process, take some time to understand the diagrams on the first two pages of the writeup.
save
before load
, even though they're presented in the opposite order. Another useful resource for this is writeTree/readTree
from section handout #16.