Question: Write a C++ program in visual studio 2019 to implement a Binary Search Tree (BST). Load the values from input file to populate your BST.

Write a C++ program in visual studio 2019 to implement a Binary Search Tree (BST). Load the values from input file to populate your BST. Search values to see your BST contains it and print the result.

1. Implement a BST using your own code. 2. Load the values from input file to the BST (integers) 3. Find and print Minimum value and Maximum value from your BST. 4. Program ask for an integer input to search. 5. Search tree recursively to find a match. 6. Print the result of your search. 7. Input of -1 (negative 1) should exit the program.

Individual work required. Use your own code to implement this tree (NOT any STL). Program correctness is extremely important. Add a header with your name, program usage, details on the beginning of your program and insert enough comments throughout the program.

Hello this is my code for this assignment but it keep on giving me and error of my file cant be found when I saved my file "Random-number.data" under the same project file. Please help me out with this. Let me know where I made a mistake and how my file can be opened.

#include #include #include using namespace std; class node { public: int data; node* left; node* right; node(int d) { this->data = d; left = NULL; right = NULL; } };

node* insert(node* root, int d) {

node* n = new node(d);

if (root == NULL) { root = n; return root; } if (root->data == d) { return root; }

else if (root->data right = insert(root->right, d); }

else { root->left = insert(root->left, d); }

return root; }

node* buildBst(node* root, vector v) { for (int i = 0; i

void displayInorder(node* root) { if (root == NULL) { return; } displayInorder(root->left); cout data right); }

int maxValue(node* root) {

while (root->right != NULL) { root = root->right; }

return root->data; }

int minValue(node* root) {

while (root->left != NULL) { root = root->left; }

return root->data; }

bool search(node* root, int key) {

if (root == NULL) { return false; }

if (root->data == key) { return true; }

else if (root->data right, key); }

else { return search(root->left, key); } } int main() {

fstream myFile;

myFile.open("Random-numbers.data", ios::in);

if (!myFile) { cout

exit(1); }

vector v;

int n;

myFile >> n;

while (n != -1) { v.push_back(n);

myFile >> n; }

node* root = buildBst(NULL, v);

cout

cout

int key; cout > key;

if (key == -1) { cout

myFile.close();

return 0; }

Write a C++ program in visual studio 2019 to implement a Binary

this is the error I am getting.

Search Tree (BST). Load the values from input file to populate yourthe output im expecting is 0001
Microsoft Visual Studio Debug Console File can't be opened nln 55 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!