Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Working with other project stakeholders for support.

Answered: 1 week ago

Question

Knowledge of project management (PMI) teachings

Answered: 1 week ago