GATE Computer ScienceModerateGATE CSE · NIELIT
A BST is built by inserting 50, 30, 70, 20, 40, 60, 80, 35, 45 in this order. How many nodes lie in the right subtree of the node 30?
- A. 3
- B. 2
- C. 4
- D. 5
Correct answer: A. 3
The right subtree of 30 holds the keys greater than 30 and less than 50: 40, 35 and 45, so 3 nodes.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int f(int n) { static int c = 0; c = c 2 + n; return c; } int main() { int a = f(1); int b = f(2); int d = f(3); int e = f(4)…
- void p(int n) { if (n <= 0) return; printf("%d ", n); p(n - 2); p(n - 3); printf("%d ", n); } What does p(6) print?
- int count(unsigned x) { int c = 0; while (x) { x &= (x - 1); c++; } return c; } What is the value of count(0xB5D)?
- int a[3][4] holds a[i][j] = 4i + j (row-major, sizeof(int) = 4). What does printf("%d %d", (a[2] - 3), (a + 1) + (a + 5)); print?
- A max-heap is stored in the array [90, 70, 80, 40, 50, 60, 75, 20, 10] (index 0 is the root). After one delete-max operation (the last…
- To find both the largest and the second-largest among 16 distinct numbers, a knockout tournament is played and then the second-largest is…