题目
题目
单项选择题

AVL_BLRT_11 Refer to the AVL Tree shown in image below. Given that the node with the value 21 has just been inserted, after identifying which node becomes unbalanced first, describe the necessary rotation(s) to restore the tree's balance.

选项
A.Left rotation at 20, then right rotation at 25
B.Left rotation at 25, then right rotation at 40
C.Single right rotation at 25.
D.Single left rotation at 20.
查看解析

查看解析

标准答案
Please login to view
思路分析
To reason about the necessary rotations after inserting 21, we must consider how AVL rotations fix imbalances and which case the insertion creates. Option 1: Left rotation at 20, then right rotation at 25. - This describes a double rotation (left-right) where the left child (20) is rotated left, followed by a rotation right at the unbalanced node (25). - If the insertion of 21 causes the subtree rooted at 25 to become left-heavy with a right-heavy grandchild (i.e., a left-right case), performing a left rotation on the left child (......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!