0
Why this function dosn't work?
This function gets a binary tree and returns the height of it, when the program runs it results in an error because the function recursion gets a null tree, how do i fix it, and is there a better way to find the height of the tree? I know i should check each sub tree in each size but i couldn't figure a way to do it. template <class T> int GetHeightOfTree(BinTreeNode<T> top) { if (&top == NULL) return -1; return 1 + fmax(GetHeightOfTree(*top.GetLeft()), GetHeightOfTree(*top.GetRight())); }
1 Answer
0
Bennett Post Ill try it ,thanks