Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to implement a yes/no guessing game. The idea is that you construct a bi

ID: 3551617 • Letter: Y

Question

You are to implement a yes/no guessing game. The idea is that you construct a binary tree where each leaf has the name of an object and each branch node has a yes/no question that distinguishes between the objects. It

The main program is called QuestionMain.java. You are to write a class called QuestionNode.java (your tree node class) and QuestionTree.java. In defining your tree node class: you should decide what data fields you need for solving this particular problem. In other words, you don't have to use a generic binary tree; you can use one that is highly specific to this program. Your node class should have at least one constructor. It can have more than one: but don't include any constructors that you don't actually use in your QuestionTree class. Your QuestionTree class should store the binary tree and should have the following public methods: A log of execution is provided at the end of this write-up showing how the program should interact using your QuestionTree class. You are to exactly reproduce the format of this log.

Explanation / Answer

(Ans-)

//CODE



Is this sufficient to achieve what the question asks? Additional code for the cpp file is below.

OUTPUT:

QUESTION: Does it have two legs? (Y or N): N

I guess that your object is a(n) horse. (Y or N): Y

Notice the superior intellect of the computer!

Play again? (Y or N): Y

You must think of a single object. Please answer the following questions about this object.

QUESTION: Does it have two legs? (Y or N): N

I guess that your object is a(n) horse. (Y or N): N

What object were you thinking of? tulip

Please specify a question that has a yes answer for your object and a no answer for my guess:

Is it a plant?

Play again? (Y or N): A

INCORRECT RESPONSE – Please type Y or N

Play again? (Y or N): Y

and so on. Any help with this question will be verry much appreciated. Thanks!

  /* BSTNode.h    Name: Vinod Shankar Menon    Description: This exercise is to show the implementation of a Binary Search Tree    The Header file contains the various operations that can be performed on the Tree.    BSTNode.h contains the declaration of class template BST.      Constructor: Constructs an empty BST      isEmpty:     Checks if a BST is empty      insert:      Inserts a value into a BST      remove:      Removes a value from a BST  */      #include <iostream>  #include <cstdlib>    using namespace std;    #ifndef BSTNODE_H  #define BSTNODE_H    class BinarySearchTree  {      private:          struct tree_node          {             tree_node* left;             tree_node* right;             string data;          };          tree_node* root;        public:          BinarySearchTree()          {             root = NULL;          }          bool isEmpty() const { return root==NULL; }          void print_preorder();          void preorder(tree_node*);          void insert(string);    };    // Smaller elements go left  // larger elements go right  void BinarySearchTree::insert(string d)  {      tree_node* t = new tree_node;      tree_node* parent;      t->data = d;      t->left = NULL;      t->right = NULL;      parent = NULL;    // is this a new tree?    if(isEmpty()) root = t;    else    {         d.substr() = no ;  //not sure what else to put here.              //Note: ALL insertions are as leaf nodes      tree_node* curr;      curr = root;      // Find the Node's parent      while(curr)      {          parent = curr;          if(t->data > curr->data) curr = curr->right;          else curr = curr->left;      }        if(t->data < parent->data)         parent->left = t;      else         parent->right = t;    }  }    void BinarySearchTree::print_preorder()  {    preorder(root);  }    void BinarySearchTree::preorder(tree_node* p)  {      if(p != NULL)      {          cout<<" "<<p->data<<" ";          if(p->left) preorder(p->left);          if(p->right) preorder(p->right);      }      else return;  }    #endif 
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote