Dsa
Trees
Warm-up
Check Balanced Binary Tree
Given a binary tree, determine if it is balanced. A tree is balanced if the height of the two subtrees of any node never differs by more than one. A tree node is defined using a Node class with properties 'value', 'left', and 'right'. Write a function that reads the level-order traversal of the tree from input and prints 'True' if the tree is balanced, and 'False' otherwise.
Input format:
A single line of integers representing the level-order traversal of the tree (0 represents a null node).
Output format:
A single boolean value ('True' or 'False').
Example:
Input:
1 2 0 3 0 0 0
Output:
True
Key concepts
treesbalancingrecursion
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