void RBTree :: inorderTreeWalk( NodePtr x ) { if ( x != nil ) { inorderTreeWalk( x->left ) ; cout << x->key << " " ; inorderTreeWalk( x->right ) ; } }
void BST :: inorderTreeWalk( NodePtr x ) { if(x != NIL) { inorderTreeWalk(x->left); cout<<x->key<<" "; inorderTreeWalk(x->right); } // You write this - it should print x->key (and a space) using cout }
/* Just prints tree in order as a horizontal list; may be used for debugging */ void RBTree :: PrintTree() { cout << "Tree elements in order:\n" ; inorderTreeWalk( root ) ; cout << "\n\n" ; }