mok/BinarySearchTree.h #ifndef BINARY_SEARCH_TREE_H #define BINARY_SEARCH_TREE_H #include "TreeNode.h" /* Incomplete BST. We will fill this out more in future lectures. */ template <typename T> class BinarySearchTree { private: TreeNode<T> *_root = nullptr; int _tree_size = 0; protected: virtual TreeNode<T> * addItemHelper(TreeNode<T> *root, T item) { //BASE CASE: null root if (root == nullptr) { //allocate new space, store value, then return. root = new TreeNode<T>{}; root->setValue(item); return root; } //RECURSIVE CASE: root is not null if (item >= root->getValue()) { //CASE 1: belongs on the right side of root TreeNode<T> *right = addItemHelper( root->getRightChild(), item ); //update right side with reconfigured state root->setRightChild(right); } else { //CASE 2: belongs on the left side of root TreeNode<T> *left = addItemHelper( root->getLeftChild(), item ); root->setLeftChild(left); } return root; } public: virtual void addItem(T value) { _root = addItemHelper(_root, value); _tree_size++; } }; #endif // BINARY_SEARCH_TREE_H mok/main.cpp #include <iostream> #include <string> #include <vector> #include <queue> #include "StringSplitter.h" #include "BinarySearchTree.h" using namespace std; void bstTest() { BinarySearchTree<int> bst{}; bst.addItem(10); bst.addItem(5); bst.addItem(2); bst.addItem(3); bst.addItem(20); bst.addItem(15); } int main() { bstTest(); return 0; } mok/mok.cbp mok/mok.layout mok/StringSplitter.h #ifndef STRING_SPLITTER_H #define STRING_SPLITTER_H #include <string> #include <vector> #include <queue> using namespace std; class StringSplitter { public: //Breaks apart the supplied text based on the given delimiter //static function do not affect the internal state //(e.g. variables) of a given class instance static queue<string> splitQ(string text, string delimiter) { //vectors are dynamically expanding arrays queue<string> pieces; //find the first delimiter int location = text.find(delimiter); //we are starting at the beginning of our string int start = 0; //go until we have no more delimiters while (location != string::npos) { //add the current piece to our list of pieces string piece = text.substr(start, location - start); pieces.push(piece); //update our index markers for the next round start = location + 1; location = text.find(delimiter, start); } //at the end of our loop, we're going to have one trailing piece to take care of. ...