Question
A tree whose elements have at-most two children is called a Binary Tree. Binary Search Tree is a node-based binary tree data structure which has
A tree whose elements have at-most two children is called a Binary Tree.
Binary Search Tree is a node-based binary tree data structure which has the following properties:
The left subtree of a node contains only nodes with keys lesser than the nodes key.
The right subtree of a node contains only nodes with keys greater than the nodes key.
The left and right subtree each must also be a binary search tree.
Using the abstract Tree class, make a tree type class named BinarySearchTree having following functionalities:
void insertNode(Type) -> inserts a new node with a key of type Type in the Tree such that the property of BST is maintained.
bool search(Type) -> returns true if key of type Type is found in the binary search tree and false if the key isnt present.
Your program should be menu based and should ask the user what action he wishes to perform.
Note: Write constructor and destructor as well.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started