Friday, January 17, 2014

Find largest Binary Search Tree in a Binary Tree

Find the largest Binary Search Tree in a given Binary Tree.

...Solution will be posted soon.

Update : Solution

Traverse the tree. From each node to the parent, return the following
set of values.

1) If BST, size of the current BST or -1 if the tree is not.
2) Minval & Maxval of the subtree and maxbstsize seen so far (
probably using references)

So in each node check the following:



Post a Comment