Check if Binary Tree is Balanced
📖 Scenario: Imagine you are building a program to check if a family tree is well balanced. A balanced tree means no branch is too long compared to others, making it easier to find family members quickly.
🎯 Goal: You will create a binary tree, add a helper variable, write a function to check if the tree is balanced, and finally print the result.
📋 What You'll Learn
Create a binary tree with the exact nodes and structure given
Add a helper function to calculate height
Write a function called
isBalanced that returns true if the tree is balancedPrint
"Balanced" if the tree is balanced, otherwise print "Not Balanced"💡 Why This Matters
🌍 Real World
Balanced trees are used in databases and file systems to keep data organized for fast searching and updating.
💼 Career
Understanding tree balance helps in roles like software development, data engineering, and system design where efficient data structures are crucial.
Progress0 / 4 steps