Question: 2 . AVL Trees ( 4 0 points ) - Which of the trees shown below are balanced? Fill in the code with the ids
AVL Trees points
Which of the trees shown below are balanced? Fill in the code with the ids for the balanced trees. eg if a was a balanced tree, you should return a list with a included Back up your decision by determining the balance factor of the root node in each of these trees! points
class Question:
@staticmethod
def balancedTrees:
Return the list of trees that are balanced.
Choose all that applies from abc and d
For example, if you think a c are balanced and b d
are unbalanced, you should return ac
return
@staticmethod
def balanceFactors:
Return the balance factor of each tree at root
When calculating the balance factor, using left height right height.
return
a: # balance factor for root node for tree a
b: # balance factor for root node for tree b
c: # balance factor for root node for tree c
d: # balance factor for root node for tree d
@staticmethod
def insertion:
Fill in the AVL tree list after inserting
according to the question.
First two steps is done for you.
AVLtreelists
None,
Fill in the balance factor lists
for each steps of the AVLtreelists above.
First two steps is done for you.
balancefactors
None,
return
"AVLtreelists": AVLtreelists,
"balancefactors": balancefactors
if namemain:
pass
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
