#ifndef TREES_HPP #define TREES_HPP #include #include #include // Namespace for different implementations of trees namespace tree_implementation { // General nodes for Tree struct TreeNode { std::string key; std::string color; std::unique_ptr leftChild; std::unique_ptr rightChild; std::unique_ptr parent; TreeNode(std::string word); ~TreeNode(void); TreeNode(const TreeNode& rhs); TreeNode& operator=(const TreeNode& rhs); }; // General list for Tree class TreeList { public: std::unique_ptr head; TreeList(void); void InsertAtStart(std::string word); void InsertAtEnd(std::string word); void InsertAtPosition(std::string word); void Remove(std::string word); void Print(void); protected: ; private: ; }; // Base Tree class class TreeInterface { public: TreeList tree; TreeInterface(void); TreeNode* Search(std::string wordToFind); bool IsSearchSuccessful(std::unique_ptr foundNode); void InOrderTreeTraversal(std::unique_ptr viewedNode); void PrintParentKey(std::string key); void PrintLeftChild(std::string key); void PrintRightChild(std::string key); protected: virtual void Insert(std::unique_ptr z); virtual void PrintPathToRoot(std::string key) = 0; private: TreeNode* Insert(std::unique_ptr root, std::unique_ptr newNode); TreeNode* Search(std::unique_ptr* viewedNode, std::string wordToFind); }; // Binary Search Tree operations class BinarySearchTree : public TreeInterface { public: void Insert(std::string keyToInsert); void PrintPathToRoot(std::string key); protected: ; private: ; }; // Red-Black Tree operations class RedBlackTree : public TreeInterface { public: void Insert(std::string keyToInsert); void PrintPathToRoot(std::string key); void PrintColor(std::string key); void PrintParentColor(std::string key); void PrintUncleColor(std::string key); protected: ; private: void InsertFixup(std::unique_ptr z); std::unique_ptr GetUncleNode(std::unique_ptr startNode); void LeftRotate(std::unique_ptr x); void RightRotate(std::unique_ptr x); }; } #endif