Answered step by step
Verified Expert Solution
Link Copied!

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* Parent(BSTNode* 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 SearchNodeREC(BSTNode* root, int data); // Recursive version
bool SearchNodeITE(BSTNode* root, int data); // Iterative version
void InsertNodeREC(BSTNode** root, int data); // Recursive version
void InsertNodeITE(BSTNode** 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

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions