GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many different max-heaps (valid arrays) can be formed using the 10 distinct keys 1 to 10?
- A. 3360
- B. 1680
- C. 3612
- D. 800
Correct answer: A. 3360
The shape of a 10-node heap has 6 nodes in the left subtree and 3 in the right. H(n) = C(n-1, l) H(l) H(r) with H(1) = H(2) = 1, H(3) = 2, H(6) = 20: C(9,6) x 20 x 2 = 84 x 40 = 3360.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A hash table of size 11 uses linear probing with h(k) = k mod 11. Keys 43, 22, 33, 54, 65, 76, 87, 14, 25 are inserted in this order (no…
- A table of size 11 uses quadratic probing h(k, i) = (k mod 11 + i^2) mod 11. Keys 23, 34, 45, 56, 67, 78, 89 (all congruent to 1 mod 11)…
- Twenty keys are hashed into a chained table with 8 slots, each key independently and uniformly. What are the expected number of colliding…
- struct node { int d; struct node n; }; struct node f(struct node p, int k) { if (p == NULL) return NULL; struct node cur = p, prev = NULL…
- Keys 5, 3, 8, 3, 9, 1, 8, 5 are inserted one by one into an initially empty sorted singly linked list; each insertion scans from the head…
- Two sorted lists, X with 5 keys and Y with 7 keys (all 12 keys distinct), are merged with the standard two-pointer merge that stops…