Write a recursive function that tests whether an element belongs to a \(BST\).


Difficulty level
This exercise is mostly suitable for students
int belong_bst_rec(BST B, int v)
{
	if (!B)
		return 0;
	if (B->data == v)
		return 1;
	if (B->data > v)
		return belong_bst_rec(B->left, v);
	return belong_bst_rec(B->right, v);
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Heapsort complexity