Write a C++ integer binary search tree program that will insert nodes, delete no
ID: 3634968 • Letter: W
Question
Write a C++ integer binary search tree program that will insert nodes, delete nodes, search for a node, and print the tree out in order.Explanation / Answer
#include"stdafx.h" #include #include using namespace std; void insert_tail(); void disp(); struct node { int data; node *ptr; }; node *temp, *temp2; node *st = NULL; void main() { st = new node(); st->data=10; st->ptr=NULL; for(int i=1; idata; temp->ptr =NULL; temp2=st; while(temp2->ptr!=NULL) { temp2=temp2->ptr; } temp2->ptr = temp; } insert_tail(); disp(); getch(); } void insert_tail() { temp = new node; couttemp->data; temp->ptr=NULL; if(st==NULL) { st=temp; } else { while(temp2->ptr!=NULL) { temp2=temp2->ptr; } temp2->ptr = temp; temp=st; } } void disp() { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.