The Gateway to Computer Science Excellence
+1 vote

Mark the balance factor of each on the tree given on the below figure and state whether it is height-balanced.

in DS by
edited by | 294 views

2 Answers

+2 votes
Balance Factor $=$ height $($left Sub Tree$)−$ height $($right Sub Tree$)$

for height balance tree, balance factor of every node  should be from $ -1  \ to \ 1 \ \  i.e. (-1,0,1)$

So, given tree is height balanced tree.
edited by
+1 vote


Balancing factor: | height of left subtree - height of right subtree |.

I have marked the balancing factors of all nodes.

Since there is no node that has balancing factor as >=2. Hence, we can say that the tree is balanced.


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,375 questions
60,583 answers
95,405 users