Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BST.h code #ifndef BST_h #define BST_h struct Node { long data; Node* left; Node* right; }; void traverse(Node* root){ if (root != NULL){ traverse (root->left);

image text in transcribed

BST.h code #ifndef BST_h #define BST_h struct Node { long data; Node* left; Node* right; }; void traverse(Node* root){ if (root != NULL){ traverse (root->left); std::cout data right); } } Node* insert(Node* root, long value){ if (root == NULL){ root = new Node; root->data = value; root->left = NULL; root->right = NULL; } else{ if (value data){ root->left = insert(root->left, value); } else{ root->right = insert(root->right, value); } } return root; } bool search (Node* root, long value){ if (root == NULL){ return false; } else{ if (root->data == value){ return true; } else if (value data){ return search(root->left, value); } else { return search(root->right, value); } } } #endif

// // A small library for sampling random numbers from a uniform distribution // #ifndef RandomSupport_h #define RandomSupport_h #include  RandomSupport.h code typedef std::uniform_int_distribution uniform_distribution; typedef std::mt19937 randomizer; randomizer new_randomizer(){ randomizer rng; rng.seed(std::random_device()()); return rng; } uniform_distribution new_distribution(long start, long end){ uniform_distribution dist(start, end); return dist; } long sample(uniform_distribution& dist, randomizer& r){ return dist(r); } #endif /* RandomSupport_h *

My code so far:

#include

#include

struct node{

int key;

struct node*left,*right;

};

struct node*newnode (int item){

struct node*temp=(struct node*)malloc (sizeof(struct node));

temp->key=item;

temp->key=temp->right=NULL;

return temp;

}

void inorder (struct node*rook){

if(root!=NULL){

inorder(root->left);

printf("%",root->key);

inorder (root->right);

}

}

struct node*insert(struct node*node, int key){

if(node==NULL)return newnode(key);

if(keykey)

node->left=insert(node->left,key);

else if (key>node->key)

node->right=insert(node->right,key);

return node;

}

Plz help!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Differentiate between hard and soft measures of service quality.

Answered: 1 week ago

Question

Be familiar with the different perspectives of service quality.

Answered: 1 week ago