Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ implement insert() in the following code and show the results of inserting 2, 1, 4, 5, 9, 3, 6, 7, 10, 12, 11

In C++ implement insert() in the following code and show the results of inserting 2, 1, 4, 5, 9, 3, 6, 7, 10, 12, 11 into an empty Binary search tree. Start with this tree and implement delete_node() and delete 4 then delete 9. Using this code with the deleted nodes, implement search() and search 12 then search 4.

image text in transcribed

I can get the nodes inserted but something is wrong when I delete because it says that 4 is found when it shouldn't after it is deleted.

#include #include using std::cout; using std::endl; class Node { int value; public: Node* left; Node* right; Node* p; // left child // right child // parent Node (int data) { value = data; left = NULL; = NULL; right = NULL; ~Node () { int d() { return value; void print() { std::cout

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