How many rotations are required during the construction of an AVL tree if the following elements are inserted in the given sequence?
35, 50, 40, 25, 30, 60, 78, 20, 28
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. 3 left rotations, 2 right rotations
Explanation
40 causes an RL case at 35 (right + left). 30 causes an LR case at 35 (left + right). 78 causes an RR case at 50 (left). 20 and 28 need none. Total: 3 left, 2 right.More Data Structures and Algorithms questions
- Consider the following undirected graph with vertices a, b, c, f, g, h and edges: a–b, a–c, a–f, b–c, b–f, b–h, c–g, f–g, f–h, g–h The foll…
- Consider the following algorithms and their running times. Which one of the following is correct?List I List II A. Breadth-first search I.…
- Consider the following statements on approximation algorithms: Statement I: APPROX-VERTEX-COVER is a polynomial-time 2-approximation algori…
- Which of the following is used to determine the cost performance index?
- Software project manager is responsible for the following task: (A) Project planning (B) Project status tracking (C) Resources management (…
- Fill in the blanks: "An ________ chart is a project schedule representation that presents the project plan as a directed graph. The critica…