GATE Computer ScienceVery hardGATE CSE · NIELIT
A complete binary tree with 100 nodes (levels filled left to right, array positions 1 to 100) is given. Let X be the number of leaves and Y the number of nodes having exactly one child. What is X + Y?
- A. 51
- B. 50
- C. 52
- D. 49
Correct answer: A. 51
Leaves are positions 51–100 so X = 50 (internal nodes are 1–50). Position 50 has only left child 100, so Y = 1. X + Y = 51.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int G(int n) { if (n < 3) return 1; return G(n-1) + G(n-2) + G(n-3); } Including the initial call, how many calls to G are made in total…
- int A(int m, int n) { if (m == 0) return n+1; if (n == 0) return A(m-1, 1); return A(m-1, A(m, n-1)); } Including the first call, how many…
- A min-heap is built from the array [19, 4, 17, 8, 2, 15, 9, 1, 12, 6, 3, 18, 11, 7, 14] by Floyd's bottom-up method: for i = ⌊n/2⌋−1 down…
- Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 10, 25, 75 are inserted in this order into an initially empty BST. Then key 30 is deleted…
- Keys 10, 20, 30, 40, 50, 25, 5, 4, 3, 35, 45, 60, 55, 52 are inserted in this order into an initially empty AVL tree. Count every single…
- A hash table of size 11 uses h(k) = k mod 11 with quadratic probing: the i-th probe examines slot (h(k) + i²) mod 11, for i = 0, 1, 2, ……