Dsa
Binary Search Tree
Easy
Check if a BST is Balanced
Given a binary search tree (BST), determine whether it is height-balanced. A height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differs by more than one.
Input Format:
- The first line contains an integer N, the number of nodes in the BST.
- The following N lines each contain a single integer representing the value of the node.
Output Format:
- Print 'True' if the BST is height-balanced and 'False' otherwise.
Example:
Input:
5
10
5
15
3
7
Output:
True
Key concepts
binary_search_treebalanced_treerecursive
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now