Hey
Below is a solution. Hope it works.
Let 'n' be the size of the array we have.
max = min = array(n-1)
flag=1;
for(i=(n-2) to 0)
{
if(array(i)array(i+1))
{
if(min array(i))
{
flag = 0;
break;
}
else
{
min = array(i);
}
}
else
Input : You have been given a sequence of integers.
Now without actually constructing BST from the given sequence of
integers (assuming the sequence is pre-order) determine if each node
of BST has single child (either left or right but not both).
Output : YES if given integer sequence