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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started