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


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

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Add into a table based on coalesced hash without separated zones