Data Structures & AlgorithmsVery hardProduct-company MCQ pattern
Keys 43, 53, 63 are inserted in this order into an empty AVL tree. After AVL rebalancing (a single rotation resolves the imbalance here), what is the resulting root and its two children (left, right)?
- A. root 53, left 43, right 63
- B. root 43, left 53, right 63
- C. root 63, left 43, right 53
- D. root 53, left 63, right 43
Correct answer: A. root 53, left 43, right 63
Inserting three keys in strictly increasing order creates a RR-shaped imbalance at the first-inserted node, fixed by a single rotation that makes the middle-valued key (53) the new root, with the smallest key as its left child and the largest as its right child. Without rebalancing, the tree would stay a straight chain rooted at 43.
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
- A disjoint-set (union-find with union by rank and path compression) over 8 elements (0 to 7), each initially its own component, runs this…
- Undirected graph edges: D–C, B–C, A–C, A–B, A–D, B–D. Using a BFS 2-colouring, is this graph bipartite?
- Keys 64, 54, 44 are inserted in this order into an empty AVL tree. After AVL rebalancing (a single rotation resolves the imbalance here)…
- A binary tree has preorder traversal [23, 2, 94, 67, 57, 46, 81] and inorder traversal [2, 23, 46, 57, 67, 81, 94]. Reconstructing the…
- Build a binary min-heap in place from the array [29, 45, 8, 5, 74, 90, 69, 56, 38] using bottom-up heapify (sift-down from the last…
- Keys 45, 92, 18, 65, 91, 86, 78, 95 are inserted in this order into an empty BST (no rebalancing). What is the height of the tree (edges…