Finding the largest subtree in a BST

前端 未结 9 741
别那么骄傲
别那么骄傲 2020-12-28 11:02

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

9条回答
  •  执念已碎
    2020-12-28 11:28

    To solve the above problem:

    1. one can do an IN-order traversal of the tree
    2. Store it in a array and find the 'largest sorted subset'.

提交回复
热议问题