Question bank › Binary Search Tree
Dsa Binary Search Tree Easy

Balanced BST Checker

Write a function that checks if a binary search tree (BST) is balanced. A balanced tree is defined as a tree where the height of the left and right subtrees of any node differ by at most one. Your function should return True if the tree is balanced and False otherwise. Input format: The input consists of an integer n, the number of nodes in the tree. The following n lines each contain an integer representing the value of a node in level order (breadth-first). A value of -1 indicates that a node does not exist. Output format: Print "True" if the BST is balanced, otherwise print "False". Example: Input: 5 3 1 4 -1 -1 -1 -1 Output: True

Key concepts

binary_search_treebalancingrecursion

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.