Question: In C + + please create a class for EmployeeInfo that contains: Employee ID Number int Employee Name string Implement a binary search tree whose
In C please create a class for EmployeeInfo that contains:
Employee ID Number int
Employee Name string
Implement a binary search tree whose nodes hold an instance of your EmployeeInfo class. The nodes should be sorted on the Employee ID number. You will have a binary search tree class header and implementation file.
You can write your main to use the following information to test your tree:
Employee ID Number Employee Name
James B W Bevis
Romney Wordsworth
Revis Jacara
Clegg Forbes
Kalin Tros
Archibald Beechcroft
Penthor Mul
Bartlet Finchley
Latham Bine
Jeff Myrtlebank
Your main will have one binary search tree object and all of the operations on the binary search tree will be class methods. You can use the code from the book for your binary search tree class. You will also offer the following options to the user:
Search for an ID
Display the tree
Add a new employee
Remove an employee
You will submit the following:
All of program source and header files compressed into a zip file.
BinaryNode.cpp :
@file BinaryNode.cpp
#include "BinaryNode.h
#include
template
BinaryNode::BinaryNode
: itemnullptr leftChildPtrnullptr rightChildPtrnullptr
end default constructor
template
BinaryNode::BinaryNodeconst ItemType& anItem
: itemanItem leftChildPtrnullptr rightChildPtrnullptr
end constructor
template
BinaryNode::BinaryNodeconst ItemType& anItem,
std::sharedptr leftPtr,
std::sharedptr rightPtr
: itemanItem leftChildPtrleftPtr rightChildPtrrightPtr
end constructor
template
void BinaryNode::setItemconst ItemType& anItem
item anItem;
end setItem
template
ItemType BinaryNode::getItem const
return item;
end getItem
template
bool BinaryNode::isLeaf const
return leftChildPtr nullptr && rightChildPtr nullptr;
template
void BinaryNode::setLeftChildPtrstd::sharedptr leftPtr
leftChildPtr leftPtr;
end setLeftChildPtr
template
void BinaryNode::setRightChildPtrstd::sharedptr rightPtr
rightChildPtr rightPtr;
end setRightChildPtr
template
auto BinaryNode::getLeftChildPtr const
return leftChildPtr;
end getLeftChildPtr
template
auto BinaryNode::getRightChildPtr const
return rightChildPtr;
end getRightChildPtr
BinaryNode.h :
A class of nodes for a linkbased binary tree.
Listing
@file BinaryNode.h
#ifndef BINARYNODE
#define BINARYNODE
#include
template
class BinaryNode
private:
ItemType item; Data portion
std::sharedptr leftChildPtr; Pointer to left child
std::sharedptr rightChildPtr; Pointer to right child
public:
BinaryNode;
BinaryNodeconst ItemType& anItem;
BinaryNodeconst ItemType& anItem,
std::sharedptr leftPtr,
std::sharedptr rightPtr;
void setItemconst ItemType& anItem;
ItemType getItem const;
bool isLeaf const;
auto getLeftChildPtr const;
auto getRightChildPtr const;
void setLeftChildPtrstd::sharedptr leftPtr;
void setRightChildPtrstd::sharedptr rightPtr;
; end BinaryNode
#include "BinaryNode.cpp
#endif
BinaryNodeTree.cpp :
@file BinaryNodeTree.cpp
#include "BinaryNodeTree.h
#include "BinaryNode.h
#include
Protected Utility Methods Section
template
int BinaryNodeTree::getHeightHelperstd::sharedptr subTreePtr const
if subTreePtr nullptr
return ;
else
return std::maxgetHeightHelpersubTreePtrgetLeftChildPtr
getHeightHelpersubTreePtrgetRightChildPtr;
end getHeightHelper
template
int BinaryNodeTree::getNumberOfNodesHelperstd::sharedptr subTreePtr const
if subTreePtr nullptr
return ;
else
return getNumberOfNodesHelpersubTreePtrgetLeftChildPtr
getNumberOfNodesHelpers
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
