Data Structures & AlgorithmsHardProduct-company placement
Keys 53, 59, 94, 71, 34, 76, 82, 15, 62, 24 are inserted in order into an empty AVL tree. Counting a double rotation as two single rotations, how many single rotations are performed in total, and what is the final root?
- A. 3 rotations, root 59
- B. 4 rotations, root 53
- C. 4 rotations, root 59
- D. 5 rotations, root 59
Correct answer: C. 4 rotations, root 59
The rebalancing events are RR at 53, LR at 94, LL at 53: 2 single and 1 double, i.e. 2 + 2×1 = 4 rotations; the root ends as 59.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- With 2 identical eggs and at most 6 drops, what is the largest number of floors for which you can always determine the critical floor (the…
- How many subsets of {1, 3, 4, 5, 8, 10, 13} have sum exactly 20?
- Five matrices have dimensions 12×5 , 5×12 , 12×10 , 10×3 , 3×5. What is the minimum number of scalar multiplications needed to compute…
- A rod of length 8 can be cut into integer pieces; a piece of length i sells for p(i) with p(1..8) = 2, 8, 10, 13, 21, 22, 25, 28. What is…
- What is the minimum number of cuts needed to split 'abacdcab' into pieces that are all palindromes?
- What is the length of the longest common subsequence of PLATFORM and PLACEMENT, and how many DISTINCT longest common subsequences (as…