Data Structures & AlgorithmsVery hardICPC regional · GATE CS top band
Keys [43, 27, 29, 8, 44, 17, 18, 5, 4] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right, left–right and right–left cases). How many rotation operations are performed in total, where a double rotation counts as two single rotations?
- A. 9
- B. 4
- C. 3
- D. 5
Correct answer: D. 5
The insertions trigger 3 rebalancing events; the double rotations add 2 each, giving 5 rotation operations. Counting events, or the final height, is not the same quantity.
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
- Directed weighted graph on vertices F, E, D, A, B (source F, target B) with edges: F→E (4); F→D (6); D→E (-3); E→B (1); D→B (6); F→B (11)…
- Directed weighted graph on vertices A, B, C, D with edges B→A (1); B→C (5); C→D (-1); B→D (-1); C→A (-1); D→C (-2); A→D (4). Source A. Run…
- Words ['aad', 'cda', 'bb', 'aaa', 'cbc', 'cdb'] (each may be used at most once). A chain is a sequence of these words in which the first…
- Words ['aa', 'acb', 'caa', 'caa', 'cbba', 'c'] are inserted in this order into an empty trie with one node per character, shared prefixes…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–C (3), A–D (3), B–D (3), C–E (3), D–E (2). An edge is CRITICAL…
- Array A = [5, 3, 5, 3, 2, 2, 4, 4]. An increasing subsequence is chosen by INDEX positions i1 < i2 < … with A[i1] < A[i2] < … (strictly…