Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in text for your convenience: Use the heard file similar to this: #include #ifndef BT_H #define BT_H using namespace std; class BT { private:

image text in transcribedimage text in transcribedimage text in transcribed

Code in text for your convenience:

Use the heard file similar to this:

#include

#ifndef BT_H

#define BT_H

using namespace std;

class BT

{

private:

struct node

{

char data;

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 searchBST(char); //Searches BST for a specific node

void deleteNode(char); //Delete item in BST

int count(); //Count driver

int leafCount(node*); //Counts number of leaves in BST

void nodeSibling(char); //Finds sibling of a node

};

#endif

Write a program in C++ to create a Binary Search tree (BST) of characters. The program will perform these operations: Insert node(s), Traverse Preorder, Search BST, Delete node, Leaf Count, Sibling of a node and Quit. Use the heard file similar to this: #include #ifndef BT H #define BTH using namespace std; Class BT private: struct node char data; node left node* right; node* root; public: //Constructor bool isEmpty() const return rootNULL;//Check for empty void insert (char); void print_preorder); void preorderTrav(node*); void searchBST (char); void deleteNode (char); int count(); int leafCount (node); void nodeSibling (char); //Insert item in BST //Preorder traversing driver //Preorder traversing //Searches BST for a specific node //Delete item in BST //Count driver //Counts number of leaves in BST //Finds sibling of a node #end if Use the following menu in your program MENU 1. nsert node(s) 2 Traverse Preorder Search BST Delete node Leaf Count Sibling of a node 4 7. Quit Enter your choice:_

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions