template <class Type> istream operator >>( istream &in Binary Tree<Type>& tree 重载 abstracting操作符“>”,用于输入数据元素并同时创建 棵 /叉树Tree Type item cout << Construct binary tree: n cout<< input data(end with"<< Tree. Refvalue <<" tem while( item !=Tree. RefValue Tree. Insert(iem);/将数据元素tem插入到二叉树Tree中 cout < Input dataend with"<< Tree. Refvalue<<") in > item return in 2021222
2021/2/22 16 template <class Type> istream & operator >> ( istream & in , BinaryTree<Type> & Tree ) //重载abstracting 操作符“ >> ” ,用于输入数据元素并同时创建一 棵 //二叉树Tree { Type item ; cout << “ Construct binary tree : \n ” ; cout << “ input data ( end with ” << Tree.RefValue << “ ) : ” ; in >> item ; while ( item != Tree.RefValue ) { Tree.Insert ( item ) ; //将数据元素item 插入到二叉树Tree 中 cout << “ Input data ( end with ” << Tree.RefValue << “ ) : ” ; in >> item ; } return in ; }
74二叉搜索树( Binary Search Tree)P235 定乂:一棵二叉树称之为二叉搜索树,如果它满足以下条件 它或者是空树 或者左子树中结点的关键码均小于根结点的关键码, 并且右子树中结点的关键码均大于根结点的关键码 并且左子树和右子树均为二叉搜索树。 显然,二叉搜索树的中序遍历的输出序列是一严格递增的有序序列 叉搜索数的类定义 2021222
2021/2/22 17 7.4 二叉搜索树(Binary Search Tree ) P235 定义:一棵二叉树称之为二叉搜索树,如果它满足以下条件: 它或者是空树; 或者左子树中结点的关键码均小于根结点的关键码, 并且右子树中结点的关键码均大于根结点的关键码, 并且左子树和右子树均为二叉搜索树。 显然,二叉搜索树的中序遍历的输出序列是一严格递增的有序序列 二叉搜索数的类定义: