二进制搜索树,高度
Binary Search Tree, height
这是我在bst.cpp 中的高度函数
int IntBinaryTree::getHeight(TreeNode * nodePtr)
{
if(nodePtr = NULL)
return 0;
else
return (max(1+getHeight(nodePtr->left), 1+getHeight(nodePtr->right)));
}
当我在main()中调用它时。我弄错了。
这是我的主要
int main {
IntBinaryTree tree;
....
tree. getHeight();
return 0;
}
你没有说什么错误,但看起来正在改变:
if(nodePtr = NULL)
至
if(nodePtr == NULL)
^^
就是你所需要的。
相关文章:
- 有根的二进制搜索树.保留与其父级的链接
- 正在尝试重载二进制搜索树分配运算符
- 使用C++创建特殊的二叉搜索树
- 在递归二叉搜索树中搜索
- 在二叉搜索树中插入时出现分段错误
- C++二叉搜索树模板从函数返回节点
- 我可以在没有堆栈的情况下在二叉搜索树中实现迭代器吗?
- 在二叉搜索树C++中计算平均值
- 在字符串的二叉搜索树中搜索子字符串 - C++
- 在二叉搜索树中插入新元素
- 如何打印在二叉搜索树中找到的数据?
- 查找存储在二叉搜索树的所有非叶子中的数据总和?(返回整数的独立递归函数
- 这是一个二叉搜索树吗?黑客排名问题
- 二叉搜索树 - 实现"search"函数
- 递归获取二进制搜索树的高度
- 二叉搜索树中的高度函数
- 二叉搜索树的总高度
- 二进制搜索树,高度
- 计数高度为h的二叉搜索树对n个元素的所有可能的根的个数
- 计算二叉搜索树的高度