Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

find binary search tree height c++

int treeHeight(node* root) {
	if(root == NULL)
		return 0;
	else {
		int leftHeight = treeHeight(root->left);
		int rightHeight = treeHeight(root->right);
		if(leftHeight >= rightHeight)
			return leftHeight + 1;
		else
			return rightHeight + 1;
	}
}
 
PREVIOUS NEXT
Tagged: #find #binary #search #tree #height
ADD COMMENT
Topic
Name
6+7 =