Write the definition of a (recursive) member function of the BinarySearchTree class named highNodeCount() that returns the number of nodes whose data field is higher (i.e. larger) than parameter data field of the root node.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Consider the class specifications for the Binary Tree class and Binary Search Tree class below:
Note: These are identical to the class specifications provided in Module 6 Assignment
// BinaryTree.h
#include <iostream>
using namespace std;
//Definition of the Node
template <class elemType>
struct TreeNode {
elemType data;
TreeNode<elemType> *left;
TreeNode<elemType> *right;
};
//Definition of class Binary Tree
template <class elemType>
class BinaryTree {
protected:
TreeNode<elemType> *root;
public:
BinaryTree();
BinaryTree(const BinaryTree<elemType>& otherTree);
~BinaryTree(0;
bool isEmpty() const;
virtual bool search(const elemType& searchItem) const = 0;
virtual void insert(const elemType& insertItem) = 0;
virtual void deleteNode(const elemType& deleteItem) = 0;
private
int height(TreeNode<elemType> *p) const;
int nodeCount(TreeNode<elemType> *p) const;
int leafCount(TreeNode<elemType> *p) const;
};
%3D
%3D
// BinarySearchTree.h
#include "BinaryTree.h"
using names pace std;
template <class elemType>
class BinarySearchTree: public BinaryTree<elemType> {
public:
bool search(const elemTy pe& searchItem) const;
void insert(const elemType& insertItem);
void deleteNode(const elemType& deleteItem);
private
void displayAscending(TreeNode<elemType> *p) const;
TreeNode<elemType> * getTreeMax(TreeNode<elemType> *p) const;
TreeNode<elemType> * getTreeMin(TreeNode<elemType> *p) const;
};
#
$
%
Transcribed Image Text:Consider the class specifications for the Binary Tree class and Binary Search Tree class below: Note: These are identical to the class specifications provided in Module 6 Assignment // BinaryTree.h #include <iostream> using namespace std; //Definition of the Node template <class elemType> struct TreeNode { elemType data; TreeNode<elemType> *left; TreeNode<elemType> *right; }; //Definition of class Binary Tree template <class elemType> class BinaryTree { protected: TreeNode<elemType> *root; public: BinaryTree(); BinaryTree(const BinaryTree<elemType>& otherTree); ~BinaryTree(0; bool isEmpty() const; virtual bool search(const elemType& searchItem) const = 0; virtual void insert(const elemType& insertItem) = 0; virtual void deleteNode(const elemType& deleteItem) = 0; private int height(TreeNode<elemType> *p) const; int nodeCount(TreeNode<elemType> *p) const; int leafCount(TreeNode<elemType> *p) const; }; %3D %3D // BinarySearchTree.h #include "BinaryTree.h" using names pace std; template <class elemType> class BinarySearchTree: public BinaryTree<elemType> { public: bool search(const elemTy pe& searchItem) const; void insert(const elemType& insertItem); void deleteNode(const elemType& deleteItem); private void displayAscending(TreeNode<elemType> *p) const; TreeNode<elemType> * getTreeMax(TreeNode<elemType> *p) const; TreeNode<elemType> * getTreeMin(TreeNode<elemType> *p) const; }; # $ %
Write the definition of a (recursive) member function of the BinarySearchTree class named
highNodeCount() that returns the number of nodes whose data field is higher (i.e. larger) than parameter data
field of the root node.
Edit Format Table
12pt v Paragraph v
| BIU Av 2v T?v|
WP
O words
:::
Transcribed Image Text:Write the definition of a (recursive) member function of the BinarySearchTree class named highNodeCount() that returns the number of nodes whose data field is higher (i.e. larger) than parameter data field of the root node. Edit Format Table 12pt v Paragraph v | BIU Av 2v T?v| WP O words :::
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY