Computers and Technology

Here you'll write the inorder traversal function in the header file "bst. h". notice that the public inorder function calls a private recursive function _ inorder to do the actual traversal. this public-private strategy is the correct way to implement recursive functions, where the public function kicks off the recursion and the private function does the actual work. the public function is written for you, your job is to implement the private _ inorder function. he main program has been written to input a sequence of integers and build a binary search tree, which you can then output. the input sequence is followed by a negative sentinel. here's an example program run: 5025881040999-1size: 6inorder: 10 25 40 50 88 999your job is to produce that last line of output, the inorder traversal of the tree with output to cout. main. cpp is a read only file#include #include "bst. h"using namespace std; int main(){binarysearchtree tree; int key; 1. inputs values from the keyboard and builds a binary search tree; // reads input until the sentinel (a negative value) is input. the// resulting binary search tree is returned.//cin > > key; while (key > = 0){tree. insert(key); cin > > key; } 2. output size and contents (in order): //cout < < "size: " < < tree. size() < < endl; tree. inorder(); // done: return 0; }bsh. h is the file to work on./*bsh. h* binary search tree//#pragma once#include using namespace std; templateclass binarysearchtree{private: struct node{tkey key; node* left; node* right; }; node* root; // pointer to root node of tree (nullptr if empty)int size; // # of nodes in the tree (0 if empty) _inorder does the actual inorder traversal and output// to console. each key is output to the console followed// by " ", including the last key.//void _inorder(node* cur){ todo: //}public: default constructor: creates an empty tree.//binarysearchtree(){root = nullptr; size = 0; } size: returns the # of nodes in the tree, 0 if empty.//int size(){return size; } inorder: performs an inorder traversal of the tree, outputting// the keys to the console.//void inorder(){cout < < "inorder: "; _inorder(root); cout < < endl; }};

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, artursino
Me2540 week 5 assignment what do i want to know?
Answers: 1
image
Computers and Technology, 22.06.2019 16:30, aryal191
Primary tech skills are skills that are necessary for success in online education
Answers: 3
image
Computers and Technology, 22.06.2019 18:30, dpinzoner5952
Which of the following commands is more recommended while creating a bot?
Answers: 1
image
Computers and Technology, 23.06.2019 00:30, hannahrasco4051
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
Do you know the correct answer?
Here you'll write the inorder traversal function in the header file "bst. h". notice that the public...

Questions in other subjects: