Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
A B-tree has minimum degree t = 3 (every non-root node has between 2 and 5 keys) and height 2 (a root-only tree has height 0). What are the minimum and maximum numbers of keys it can hold?
- A. 18 and 215
- B. 17 and 180
- C. 17 and 215
- D. 26 and 215
Correct answer: C. 17 and 215
Minimum: root with 1 key and 2 children, then 3 children per node, each node holding 2 keys: 1 + 2(t − 1)(1 + t + … + t^1) = 2t^2 − 1 = 17. Maximum: every node full with 2t children: (2t)^3 − 1 = 215.
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
- In the grid 11111 / 11210 / 21111 / 00111 (rows top to bottom; 2 = rotten, 1 = fresh, 0 = empty), every minute each rotten orange rots its…
- What is the edit distance (insert, delete, substitute; each cost 1) between RECESSION and HEAPSORT?
- Symbols occur with frequencies 3, 4, 13, 27, 35. How many bits does an optimal (Huffman) prefix code need for the whole message, and how…
- Keys 12, 16, 26, 38, 48 are searched with frequencies 10, 1, 8, 8, 11 respectively (only successful searches). The cost of a BST is Σ…
- A min-heap holds 31 distinct keys in a 0-indexed array (a full tree with 5 levels). At how many different indices can the 3rd-smallest key…
- In how many ways can a convex polygon with 8 vertices be divided into triangles by non-crossing diagonals?