Question: C++: You will be developing a task management application. Tasks are given unique integer task IDs, and these IDs will be the KeyType for the

C++:

You will be developing a task management application. Tasks are given unique integer task IDs, and these IDs will be the KeyType for the BST. A task record will be the ItemType and will have the following fields, all of which must be stored in private instance variables:

int taskID

string taskName

int estimatedTimeToComplete

int timeAddedToBST

int timeStarted

Question:

How do I get all of these variables into one node of the binarySearchTree? Task is my class that has those private variables. So in my executive class, I tried doing BinarySearchTree tree to make the binary search tree, but that doesn't work. I'm just very confused about how to do this.

Code for BinarySearchTree.h:

#ifndef _BINARY_SEARCH_TREE #define _BINARY_SEARCH_TREE #include "NotFoundException.h" #include "BinaryNode.h" #include "InvalidSetEntryRequest.h" // The instantiating ItemType class must have the relational operators // implemented for comparing: ItemType (on the LHS) to KeyType (on RHS). // For example, given ItemType item and KeyType aKey, it must be valid // to write: // if (item == aKey) // ... // else if (item < aKey) // ... template class BinarySearchTree { private: BinaryNode* rootPtr; protected: //------------------------------------------------------------ // Protected Utility Methods Section: // Recursive helper methods for the public methods. //------------------------------------------------------------ // Recursively finds where the given node should be placed and // inserts it in a leaf at that point. BinaryNode* insertInorder(BinaryNode* subTreePtr, BinaryNode* newNode); // Removes the given target value from the tree while maintaining a // binary search tree. BinaryNode* removeValue(BinaryNode* subTreePtr, KeyType aKey, bool& success); // Removes a given node from a tree while maintaining a // binary search tree. BinaryNode* removeNode(BinaryNode* nodePtr); // Removes the leftmost node in the left subtree of the node // pointed to by nodePtr. // Sets inorderSuccessor to the value in this node. // Returns a pointer to the revised subtree. BinaryNode* removeLeftmostNode(BinaryNode* subTreePtr, ItemType& inorderSuccessor); // Returns a pointer to the node containing the given value, // or nullptr if not found. BinaryNode* findNode(BinaryNode* treePtr, KeyType aKey) const; // Recursive traversal helper methods: void preorder(void visit(ItemType&), BinaryNode* treePtr) const; void inorder(void visit(ItemType&), BinaryNode* treePtr) const; void postorder(void visit(ItemType&), BinaryNode* treePtr) const; public: //------------------------------------------------------------ // Constructor and Destructor Section. //------------------------------------------------------------ BinarySearchTree(); BinarySearchTree(const ItemType& rootItem); BinarySearchTree(const BinarySearchTree& tree); virtual ~BinarySearchTree(); //------------------------------------------------------------ // Public Methods Section. //------------------------------------------------------------ bool isEmpty() const; int getHeight() const; int getNumberOfNodes() const; bool add(const ItemType& newEntry); bool remove(const KeyType& aKey); ItemType getEntry(const KeyType& aKey) const throw(NotFoundException); // An entry in a BST can be set if and only if "item == aKey". // If this is not the case, throw InvalidSetEntryRequest. // If "aKey" does not exist in the tree, throw NotFoundException. void setEntry(const KeyType& aKey, const ItemType& item) const throw(NotFoundException, InvalidSetEntryRequest); bool contains(const KeyType& aKey) const; void clear(); //------------------------------------------------------------ // Public Traversals Section. //------------------------------------------------------------ void preorderTraverse(void visit(ItemType&)) const; void inorderTraverse(void visit(ItemType&)) const; void postorderTraverse(void visit(ItemType&)) const; //------------------------------------------------------------ // Overloaded Operator Section. //------------------------------------------------------------ BinarySearchTree& operator=(const BinarySearchTree& rightHandSide); }; // end BinarySearchTree #include "BinarySearchTree.cpp" #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!