The Gateway to Computer Science Excellence
+1 vote
136 views

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

in DS by Veteran (105k points)
edited by | 136 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.
by Boss (10.3k points)
edited by
0 votes

 

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.

by Junior (501 points)

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
50,644 questions
56,505 answers
195,555 comments
101,046 users