Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Keys [2, 42, 28, 49, 8, 35] 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. 3
- B. 1
- C. 2
- D. 6
Correct answer: C. 2
The insertions trigger 1 rebalancing events; the double rotations add 2 each, giving 2 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
- Distinct words ['a', 'cbb', 'c', 'b'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a root)…
- Directed weighted graph on vertices A, B, C, D, E with edges listed in this exact order: A→B (6); E→A (4); C→D (5); B→E (5); B→C (4); A→D…
- Distinct words ['ca', 'b', 'bac', 'a', 'c', 'bbbb'] are inserted into an empty trie (one node per character, shared prefixes sharing…
- A chain of 6 matrices M1 to M6 has dimensions given by the sequence p = [16, 18, 7, 19, 14, 15, 7], where Mi has size p[i−1] × p[i]…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (12), A–C (16), A–D (15), B–C (2), B–D (20), B–E (17), C–E…
- Directed weighted graph on vertices A, B, C, D, E with edges (u→v, w): E→B (1); A→E (3); C→E (3); C→B (8); D→C (7); D→A (9); C→D (5); D→E…