1. Implement insert() in tree.cpp and show the results of inserting 3, 2, 5, 6, 10, 4, 7, 8, 11, 15, 13 into an empty Binary search tree. 2. Start with the tree in problem 1 and implement delete node) and do: 2.1. delete 5, then 2.2. delete 8. 3. Start with the tree in problem 2 and implement search() and do: 3.1. Search 7 3.2. Search 5
How can I edit this coce to create an insert, delete, and search function in Binary tree inC++ ?
#include <iostream>
#include <cstddef>
using std::cout;
using std::endl;
class Node {
int value;
public:
Node* left; // left child
Node* right; // right child
Node* p; // parent
Node(int data) {
value = data;
left = NULL;
right = NULL;
p = NULL;
}
~Node() {
}
int d() {
return value;
}
void print() {
std::cout << value << std::endl;
}
};
int main(int argc, const char * argv[])
{
}
function insert(Node *insert_node, Node *tree_root){
}
function delete_node(int value, Node *tree_root){
//Your code here
}
function search(int value, Node *tree_root){
//Your code here
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images