Question: Data Structure with C++ Please write 3 different files BST.h , BST.cpp and main.cpp Write a C++ program to implement a Binary Search tree (

Data Structure with C++

Please write 3 different files BST.h , BST.cpp and main.cpp

Write a C++ program to implement a Binary Search tree (do not use structures). Your program should accept a list of numbers from the user (minimum 5) and then build a binary search tree from those numbers. Also, implement a search function that takes one value as an argument and prints whether or not the number was found in the list. Define three files: bst.h, bst.cpp and your main,cpp to test your code. Use the given code at the end to create the Binary Search Tree.

b) Write the definition of the function, leavesCount, that returns the number of leaves in a binary tree.

c) Print the contents of your tree using inorder traversal. You may use Stack STL if needed.

class Node

{

int info;

public:

Node(int info);

int getInfo();

void setInfo(int value);

Node *left, *right;

};

class BST

{

Node *root;

public:

BST();

~BST();

void insert(int);

void/bool search(int); //you can either make it void or bool

void inorderTraversal();

void/int leavesCount();

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!