二叉排序树的顺序存储

来源:百度知道 编辑:UC知道 时间:2024/05/06 14:08:02
谁能写一下二叉排序树顺序存储的各种操作啊?我的积分都给你咯!
2楼的同志,您的答案我不能给你积分.对不起!

二叉排序树插入操作算法
template<class Type> void BSTree<Type>::
Insert(const Type & x,BSTreeNode<Type> * & p)
{//在p为根的二叉排序树上插入节点的递归算法
if(p==NULL) //空二叉树
p=new BSTreeNode<Type>(x);//创建数据元素x的节点
else if(x< p->data) //在左子树插入
Insert(x, p->rightChild);
else if( x> p->data) //在右子树插入
Insert(x,p->rightChild);
else //节点x已存在
{cout<<"There hai node x"<<endl;
exit(1);}
}

剩下的删除操作,寻找操作等你给了分数我再写,太长了
回答完毕

楼上的,这个就是你的"顺序存储"?