Question: Exercise 2 . Calculating the tree imbalance . [ 2 0 points ] Let be a full binary tree 1 . Let be a node
Exercise
Calculating the tree imbalance
points
Let
be a
full
binary tree
Let
be a node in
and define
imbalance
to be the
absolute difference between the number of leaves in the left subtree of
and those in
its right subtree. If
is a leaf, then
imbalance
We extend the definition of
imbalance
to the entire tree
as follows:
imbalance
max
in
imbalance
a points Find an upper bound for
imbalance
Provide an example of a full
binary tree whose imbalance is maximized.
b points Draw a full binary tree
such that
imbalance
imbalance
for
some node
that is
not
the root of
Explicitly indicate which node is
and state
imbalance
for your tree.
c points Describe, in pseudocode, an efficient algorithm to compute
imbalance
Provide the running time of your algorithm and justify your analysi
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
