• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 24, 2024 |140 Views

SDE Sheet - Largest BST in Binary Tree

Description
Discussion

This video is part of the Binary Search Tree section under GFG SDE Sheet.

Given a binary tree. Find the size of its largest subtree which is a Binary Search Tree.
Note: Here Size equals the number of nodes in the subtree.

Examples :

Input:    1
            /  \
          4     4              
         / \ 
       6    8
Output: 1 
Explanation: There's no sub-tree with size greater than 1 which forms a BST. All the leaf Nodes are the BSTs with size equal to 1.

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/largest-bst/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/largest-bst-binary-tree-set-2/