true
isBST(left subtree of t)
isBST(right subtree of t)
smallerOrEqual(left subtree of t, integer of root of t)
greaterOrEqual(right subtree of t, integer of root of t)
Algorithm smallerOrEqual(t, i):
Input: binary tree whose nodes contains integers; an integer
Output: (A n : n is a node of t : element of n <= i)
result
element of root of t <= i
if t consists of more than one node then
result
result
smallerOrEqual(left subtree of t, i)
smallerOrEqual(right subtree of t, i)
return result
Algorithm isBST(t):
Input: binary tree whose nodes contains integers
Output:
(Is t a binary search tree?,
minimal integer stored in t,
maximal integer stored in t)
Complete the recursive algorithm that computes all three at the same time. What is its worst-case running time?