您的位置:首页 > 其它

编写一个程序,把一个有序整数数组放到二叉树中。

2012-05-10 09:18 453 查看
/*
编写一个程序,把一个有序整数数组放到二叉树中。
*/
void GetTree(int *tree,int low,int high,BTreeNode* &root)
{
if(low>high)
{
root=0;
return;
}
int mid=low+(high-low)/2;
root=new BTreeNode(tree[mid]);
GetTree(tree,low,mid-1,root->pleft);
GetTree(tree,mid+1,high,root->pright);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: