#ifndef BINARY_SEARCH_NODE_ITERATIVE #define BINARY_SEARCH_NODE_ITERATIVE #ifndef nullptr #define nullptr 0 #endif #include #include "Exception.h" template class Binary_search_tree; template class Binary_search_node { private: Type element; Binary_search_node *left_tree; Binary_search_node *right_tree; public: Binary_search_node( Type const & ); Type retrieve() const; Binary_search_node *left() const; Binary_search_node *right() const; bool is_leaf() const; friend class Binary_search_tree; }; template Binary_search_node::Binary_search_node( Type const &obj ): element( obj ), left_tree( nullptr ), right_tree( nullptr ) { // empty } template Type Binary_search_node::retrieve() const { return element; } /* * Binary_search_node *left() const * Binary_search_node *right() const * * Returns the addresses of the left and right sub-trees, respectively. */ template Binary_search_node *Binary_search_node::left() const { return left_tree; } template Binary_search_node *Binary_search_node::right() const { return right_tree; } /* * bool is_leaf() const * * A node is a leaf node if both its sub-trees are empty. */ template bool Binary_search_node::is_leaf() const { return ( left() == nullptr ) && ( right() == nullptr ); } #endif