GATE Computer ScienceVery hardGATE CSE · ISRO
How many different arrays A[1..9] that are permutations of {1,…,9} satisfy the min-heap property (A[i] ≥ A[⌊i/2⌋] for every i ≥ 2)?
- A. 896
- B. 1792
- C. 886
- D. 448
Correct answer: A. 896
The count is 9!/∏(subtree sizes of the 9-node heap shape) = 362880/(9·5·3·3) = 896, verified by enumerating all 9! arrays: 896.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using…
- The KMP failure (prefix) function π[i] of pattern P = "abaabaabaabab" gives, for each prefix P[0..i], the length of its longest proper…
- A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50…
- A hash table of size 13 uses double hashing: the i-th probe for key k is (k mod 13 + i·(1 + k mod 11)) mod 13. The keys 18, 41, 22, 44…
- Keys 40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 80, 3, 12, 23, 27, 90 are inserted into an empty BST. How many nodes have a…
- In a knockout (tournament-tree) method, what is the minimum number of comparisons needed in the worst case to find both the smallest and…