Data Structures & AlgorithmsVery hardGATE CS · Advanced
Keys 50, 20, 60, 10, 30, 40, 70, 45, 42, 48, 5, 3 are inserted one by one, in this order, into an initially empty AVL tree. A double rotation counts as two rotations. What is the key at the root at the end and how many rotations were performed in total?
- A. root 42, 8 rotations
- B. root 42, 9 rotations
- C. root 42, 7 rotations
- D. root 50, 8 rotations
Correct answer: A. root 42, 8 rotations
Simulate with balance checks after every insertion: final root 42, 8 rotations (a double rotation is two). The unbalanced BST would keep 50 as root with height 6, which an AVL tree does not allow.
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
- Keys 10, 20, 30, 40, 50, 60, 70, 80, 15, 25, 35, 45 are inserted in this order into an empty B-tree of minimum degree t = 2 (every node…
- The words car, card, care, cart, cat, dog, dot, dove, do, door are stored in a trie (one letter per edge, with a flag marking the end of a…
- A disjoint-set forest on elements 1..10 starts with every element as its own root. Union(a, b) finds both roots (find uses full path…
- A tree on the vertices A–J has the edges A–B, B–C, C–D, A–E, D–F, B–G, F–H, A–I, C–J. What is the sum of the distances over all unordered…
- A directed acyclic graph has the vertices A–G and the arcs D→F, D→C, D→B, G→C, G→A, C→A, C→E, C→B. How many different topological…
- In a bipartite graph the left vertices are L1–L6 and the right vertices are R1–R6, with the edges L1–R3, L1–R5, L1–R6, L2–R3, L3–R2…