here is the code i have right now i will include screenshots of my output(black background) and my wanted output(white background). in option 1 it asks how many nodes i want to insert into the list i type 4 i want the 4 to be KIM PAM DON TOM  but the result of my current output is KIM P it counts each individual string. in C++ please fix thank you. //bt.h - header file contains the object description #include //bt.h #define BT_H using namespace std; class BT { private:     struct node     {         char data;  //whatever is the data type; use that         node* left;         node* right;     };     node* root; public:     BT();                                            //Constructor     bool isEmpty() const { return root == NULL; }    //Check for empty     void insert(char);                                //Insert item in BST     void print_preorder();                            //Preorder traversing driver     void preorderTrav(node*);                        //Preorder traversing     void print_inorder();                            //Preorder traversing driver     void inorderTrav(node*);                        //Preorder traversing     void print_postorder();                            //Preorder traversing driver     void postorderTrav(node*);                        //Preorder traversing                  }; //MAIN  #include "bt.h" #include using namespace std; //Constructor BT::BT() {     root = NULL; } void BT::insert(char d) {     node* t = new node;     node* parent;     t->data = d;     t->left = NULL;     t->right = NULL;     parent = NULL;     if (isEmpty())     {         root = t;     }     else     {         //Note: ALL insertions are as leaf nodes         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;         }     } } cout << "Inserted." << endl; } SOURCE  #include "bt.h" #include using namespace std; int main() {     BT b;     int ch, num;     char d;     cout << "-----------Menu-------------" << endl;     cout << endl;     cout << "1. Insert node(s)" << endl;     cout << "2. Traverse Preorder" << endl;     cout << "3. Traverse Inorder" << endl;     cout << "4. Traverse Inorde" << endl;     cout << "5. Quit" << endl << endl;     do     {         cout << endl << "Enter Your Choice <1 - 5> ";         cin >> ch;         switch (ch)         {         case 1:             cout << "Enter number of nodes to insert: ";             cin >> num;             for (int i = 0; i> d;                 b.insert(toupper(d));                 cout << "Inserted." << endl;             }             break;

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter12: Working With Document Nodes And Style Sheets: Creating A Dynamic Document Outline
Section12.1: Visual Overview: Exploring The Node Tree
Problem 2QC
icon
Related questions
Question
100%

here is the code i have right now i will include screenshots of my output(black background) and my wanted output(white background).

in option 1 it asks how many nodes i want to insert into the list i type 4 i want the 4 to be KIM PAM DON TOM 

but the result of my current output is KIM P it counts each individual string. in C++ please fix thank you.

//bt.h - header file contains the object description
#include <iostream>
//bt.h
#define BT_H
using namespace std;

class BT
{
private:
    struct node
    {
        char data;  //whatever is the data type; use that
        node* left;
        node* right;
    };
    node* root;
public:
    BT();                                            //Constructor
    bool isEmpty() const { return root == NULL; }    //Check for empty
    void insert(char);                                //Insert item in BST
    void print_preorder();                            //Preorder traversing driver
    void preorderTrav(node*);                        //Preorder traversing
    void print_inorder();                            //Preorder traversing driver
    void inorderTrav(node*);                        //Preorder traversing
    void print_postorder();                            //Preorder traversing driver
    void postorderTrav(node*);                        //Preorder traversing
                
};

//MAIN 

#include "bt.h"
#include <iostream>
using namespace std;
//Constructor
BT::BT()
{
    root = NULL;
}

void BT::insert(char d)
{
    node* t = new node;
    node* parent;

    t->data = d;
    t->left = NULL;
    t->right = NULL;
    parent = NULL;

    if (isEmpty())
    {
        root = t;
    }
    else
    {
        //Note: ALL insertions are as leaf nodes
        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;
        }
    }
}
cout << "Inserted." << endl;
}

SOURCE 
#include "bt.h"
#include <iostream>
using namespace std;
int main()
{
    BT b;
    int ch, num;
    char d;

    cout << "-----------Menu-------------" << endl;
    cout << endl;
    cout << "1. Insert node(s)" << endl;
    cout << "2. Traverse Preorder" << endl;
    cout << "3. Traverse Inorder" << endl;
    cout << "4. Traverse Inorde" << endl;
    cout << "5. Quit" << endl << endl;

    do
    {
        cout << endl << "Enter Your Choice <1 - 5> ";
        cin >> ch;
        switch (ch)
        {
        case 1:
            cout << "Enter number of nodes to insert: ";
            cin >> num;
            for (int i = 0; i<num; i++)
            {
                //cout << endl;
                cout << "Enter node: ";
                cin >> d;
                b.insert(toupper(d));
                cout << "Inserted." << endl;

            }
            break;

Enter Your Choice <1 - 5> 1
Enter number of nodes to insert: 4
Enter node: KIM
Inserted.
Enter node: Inserted.
Enter node: Inserted.
Enter node: P
Inserted.
Enter Your Choice <1 - 5>
Transcribed Image Text:Enter Your Choice <1 - 5> 1 Enter number of nodes to insert: 4 Enter node: KIM Inserted. Enter node: Inserted. Enter node: Inserted. Enter node: P Inserted. Enter Your Choice <1 - 5>
Enter Your Choice <1-7> 1
Enter number of items to insert: 4
Enter node: KIM
Inserted.
Enter node: PAM
Inserted.
Enter node: DON
Inserted.
Enter node: TOM
Inserted.
Transcribed Image Text:Enter Your Choice <1-7> 1 Enter number of items to insert: 4 Enter node: KIM Inserted. Enter node: PAM Inserted. Enter node: DON Inserted. Enter node: TOM Inserted.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning