Data Structures & AlgorithmsHardProduct-company placement
Keys 85, 36, 65, 27, 34, 80, 17, 66, 97, 68 are inserted in order into an empty AVL tree. Counting a double rotation as two single rotations, how many single rotations are performed in total, and what is the final root?
- A. 3 rotations, root 65
- B. 5 rotations, root 85
- C. 5 rotations, root 65
- D. 6 rotations, root 65
Correct answer: C. 5 rotations, root 65
The rebalancing events are LR at 85, LR at 36, LL at 85: 1 single and 2 double, i.e. 1 + 2×2 = 5 rotations; the root ends as 65.
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 rooted tree has 2 nodes with 1 child, 6 nodes with 2 children, 5 nodes with 3 children, and every other node is a leaf. How many leaves…
- The directed graph A→B (6), A→C (5), A→D (8), A→E (4), C→B (5), C→E (1), D→B (-3), E→B (2) has one negative edge but no negative cycle…
- A directed graph on A–H has edges A→H, B→D, B→E, B→H, C→H, D→C, E→A, E→F, F→A, F→D, G→H. How many strongly connected components does it…
- Unit-time jobs (deadline, profit): J1 (3, 34), J2 (3, 62), J3 (3, 67), J4 (4, 10), J5 (3, 27), J6 (3, 79), J7 (3, 89). One job runs at a…
- Floyd–Warshall runs on vertices 1–4 with directed edges 1→2 (4), 2→3 (11), 2→4 (11), 3→1 (7), 3→2 (6), 3→4 (8), 4→3 (11). After the…
- An undirected connected graph has edges A–B, A–E, B–G, C–G, D–E, D–G, D–I, E–G, E–I, F–H, H–I. How many articulation points (cut vertices)…