Data Structures & AlgorithmsHardGATE CS · Product-company placement
Keys 88, 38, 16, 75, 87, 68, 51, 36, 82, 61 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. 4 rotations, root 75
- B. 7 rotations, root 88
- C. 7 rotations, root 75
- D. 8 rotations, root 75
Correct answer: C. 7 rotations, root 75
The rebalancing events are LL at 88, LR at 88, RL at 38, LR at 68: 1 single and 3 double, i.e. 1 + 2×3 = 7 rotations; the root ends as 75.
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
- In how many different ways can 'catsanddogs' be split into a sequence of words from the dictionary {cat, cats, and, sand, dog, dogs, s}…
- The boolean expression T ^ T | T ^ F (T = true, F = false, & = AND, | = OR, ^ = XOR) can be fully parenthesised in 5 ways. In how many of…
- What is the edit distance (insert, delete, substitute; each cost 1) between MATRIX and STRATEGY?
- A B-tree has minimum degree t = 3 (every non-root node has between 2 and 5 keys) and height 3 (a root-only tree has height 0). What are…
- How many subsets of {1, 4, 8, 9, 10, 11, 12} have sum exactly 27?
- What is the maximum flow from S to T in the network with directed capacities A→B (15), A→C (9), A→T (12), B→T (12), C→B (12), S→A (6), S→B…