GATE Computer ScienceVery hardGATE CSE · NIELIT
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 invocations of A occur while evaluating A(2, 3)?
- A. 30
- B. 70
- C. 88
- D. 44
Correct answer: D. 44
A(2,3) = 9; counting every invocation of the recursion (a(2,n) = 2n+3 style growth) gives 44 calls.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- 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, ……
- The integers 1, 2, 3, 4, 5, 6 are pushed in this order onto a stack; pops can be interleaved with pushes at any time and every element is…
- How many structurally distinct binary trees (left and right children distinguished) with exactly 7 nodes have height exactly 3, where…