Re: [algogeeks] Determine if BST has single child for every node given pre order

2011-12-31 Thread Apoorve Mohan
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

[algogeeks] Determine if BST has single child for every node given pre order

2011-12-29 Thread top coder
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