Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Keys [49, 47, 26, 15, 3, 33, 12, 19, 21] 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. 7
- C. 5
- D. 4
Correct answer: B. 7
The insertions trigger 5 rebalancing events; the double rotations add 2 each, giving 7 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 A, B, C, D, E with edges A→C (6); A→E (2); C→A (-2); C→B (1); D→A (1); E→C (5); C→E (3); E→D (2); D→E…
- Rooted tree with root 0 and vertices 0 to 8; the edges are 0–1, 1–2, 2–3, 1–4, 1–5, 4–6, 4–7, 6–8 (parent–child). Every edge has length 1…
- Undirected weighted graph on vertices A, B, C, D, E, F; its edges, in this listed order, are: B–E (3), C–E (4), B–C (8), E–F (2), D–F (7)…
- Array [28, 17, 3, 22, 8, 23, 10] is turned into a min-heap in place with bottom-up heapify: for i from ⌊n/2⌋−1 down to 0, sift the element…
- Bipartite graph with left side {A, B, C}, right side {D, E, F, G} and edges A–D, A–E, B–F, B–G, C–D. What is the size of a maximum…
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→B (4)…