Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This week, we start to implement the Binary Search Tree ( BST ) . In this Binary Search Tree, we consider nodes that contain a
This week, we start to implement the Binary Search Tree BST
In this Binary Search Tree, we consider nodes that contain a key of type int. The first step is to implement a class BSTNode. In this class, create the following
elements:
Constructor by default no input
Constructor that specifies the value of a key
Destructor it does nothing
Function that determines if the node is a leaf or not.
Function that returns the number of children.
Create a function that returns the parent of a node child.
BSTNode ParentBSTNode root,BSTNode child;
Create a function to search if an element is present in the tree.
Create a function to insert an element in the tree.
bool SearchNodeRECBSTNode root, int data; Recursive version
bool SearchNodeITEBSTNode root, int data; Iterative version
void InsertNodeRECBSTNode root, int data; Recursive version
void InsertNodeITEBSTNode root, int data; Iterative version
For each function, start by implementing the base case, and then the recursive calls.
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