Data Structures & AlgorithmsHardHCLTech · Wipro pattern
Keys 27, 96, 68, 47, 51, 92, 12 are inserted in this order into an empty BST (no rebalancing). What is the height of the tree (edges on the longest root-to-leaf path)?
- A. 3
- B. 4
- C. 5
- D. 2
Correct answer: B. 4
Inserting keys in this order without rebalancing produces a tree whose deepest leaf is 4 edges below the root. 2 would be the height of a *balanced* tree with 7 nodes, which insertion order alone does not guarantee.
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
- An undirected graph has adjacency lists (neighbours visited in alphabetical order) A: [G]; B: [C]; C: [B, D]; D: [C, F, G]; E: [F]; F: [D…
- Keys 35, 45, 55 are inserted in this order into an empty AVL tree. After AVL rebalancing (a single rotation resolves the imbalance here)…
- Keys 60, 70, 80 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 [90, 31, 36, 77, 58, 43, 83] and inorder traversal [31, 36, 43, 58, 77, 83, 90]. Reconstructing the…
- Undirected graph edges: A–D, D–C, B–C, C–A. Using a BFS 2-colouring, is this graph bipartite?
- Keys 57, 11, 34, 33, 80, 9, 72, 24, 56, 66 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain)…