Finding the largest subtree in a BST
Posted
by rakeshr
on Stack Overflow
See other posts from Stack Overflow
or by rakeshr
Published on 2010-02-25T17:31:17Z
Indexed on
2010/05/02
15:37 UTC
Read the original article
Hit count: 273
Given a binary tree, I want to find out the largest subtree which is a BST in it.
Naive approach:
I have a naive approach in mind where I visit every node of the tree and pass this node to a isBST function. I will also keep track of the number of nodes in a sub-tree if it is a BST.
Is there a better approach than this ?
© Stack Overflow or respective owner