Question: In this exercise, you will be writing a function that counts the number of times a given value occurs in a binary search tree. Assume

In this exercise, you will be writing a function that counts the number of times a given value occurs in a binary search tree. Assume that in our tree, if the same value is inserted more than once, subsequent copies go to the right of the original.

Download and study the files BSTcomplete.h, which contains an implementation of a Binary Search Tree along with the operations we have studied in class, finalBST.cpp, which is a program that inserts some values into an empty tree and calls the occurrencesfunction on some value, in order to determine how many times it appears in the tree. The file where you need to implement your occurrencesfunction is BSTOps.h

Long story short, make it so that finalBST.cpp compiles and runs, and that it produces the expected output. Uploaf your modified BSTOps.h file here.

finalBST.cpp

#include  #include "BSTComplete.h" #include "BSTOps.h" using namespace std; int main(int argc, const char * argv[]) { Node* tree = NULL; tree = insert(tree, 6); tree = insert(tree, 2); tree = insert(tree, 7); tree = insert(tree, 6); tree = insert(tree, 6); tree = insert(tree, 6); tree = insert(tree, 7); cout << occurrences(tree, 7) << endl; return 0; }

BSTOps.h

#ifndef BSTOps_h #define BSTOps_h #include "BSTComplete.h" int occurrences(Node* root, int value){ // Provide your code here } #endif

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!