GATE Computer ScienceHardGATE CSE · NIELIT
A binary tree has preorder 8 3 1 6 4 7 10 14 13 and inorder 1 3 4 6 7 8 10 13 14. What is its postorder traversal?
- A. 1 4 7 6 3 14 13 10 8
- B. 1 4 7 6 3 13 14 10 8
- C. 1 3 4 7 6 13 14 10 8
- D. 1 4 6 7 3 13 14 10 8
Correct answer: B. 1 4 7 6 3 13 14 10 8
The root is 8; 3's subtree is {1,3,4,6,7} and 10's is {10,13,14}. Postorder: 1 4 7 6 3 13 14 10 8.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int c = 0; for (int i = 1; i < 100; i = 2) for (int j = 0; j < i; j++) c++; What is the final value of c?
- void f(int a[], int n) { a[0] = n; n = a[1]; a = a + 1; a[0] = 99; } int main() { int x[3] = {1, 2, 3}; int m = 5; f(x, m); printf("%d %d…
- How many structurally distinct binary search trees on 6 keys have height exactly 3, where height is the number of edges on the longest…
- In how many different ways can the keys 1, 2, …, 7 be arranged in the array of a binary max-heap (every parent greater than its children)?
- A binary max-heap is built from 15 elements by Floyd's bottom-up method (sift-down from the last internal node to the root). Each level of…
- 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)); } How many times is A…