Recursion Mcqs
Our collections of Multiple choice questions and answers focuses on study of ” Recursion ” in Data Structures. These questions are chosen from a collection of most authoritative and best reference books on Data Structures. Our aim is to prepare an individual for competitive exams like NTS | GAT | ECAT | Data Warehouse jobs | Data Mining | DB administration jobs Software House and Computer Programmer jobs | University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate knowledge on Recursion comprehensively.
17. Consider the following code:Which of the following is the base case for the above recursive code?
If(n == 0)
Return 0
Return n + recursive_sum(n – 1)
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
18. Consider the following code:Which of the following lines is the base case for thebelow code?
If(n ==0 && len == 0)
If(n == 0)
If(n ==0 && len == 0) and if(n == 0)
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
19. Consider the following code:Which of the following lines is the recurrence relation for thebelow code?
(n – 1) +recursive_sum(n)
N + recursive_sum(n)
N + recursive_sum(n – 1)
(n – 1) + recursive_sum(n – 1)
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
20. Consider the following iterative code snippet to find the largest element:Which of the following lines should be inserted to complete the below code?
Arr[i] > max_element
Arr[i] < max_element
Arr[i] == max_element
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
21. Consider the following iterative code used to convert a decimal number to its equivalent binary:Which of the following lines should be inserted to complete thebelow code?
N–
N /= 2
N /= 10
N++
22. Consider the following iterative implementation to find the factorial of a number:Which of the following lines should be inserted to complete thebelow code?
Fact = fact + i
Fact = fact * i
I = i * fact
I = i + fact
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
23. Consider the following iterative implementation to find the length of the string:Which of the following lines should be inserted to complete thebelow code?
S[len-1] != 0
S[len+1] != 0
S[len] != ‘ ’
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
24. Consider the following iterative implementation to find the nth fibonacci number:Which of the following lines should be added to complete thebelow code?
C = b
b = a
A = b
b = c
B = c
a = b
A = b
b = a
Answer & Solution
b = c
No Solution for this Answer..! Report or Discus this Question
25. Consider the following iterative implementation to find the sum of digits of a number:Which of the following lines should be inserted to complete thebelow code?
Sm += n
Sm += n%10
Sm += n-10
Sm += n/10
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
26. Consider the following iterative implementation used to find the length of a linked list:Which of the following conditions should be checked to complete thebelow code?
Temp->next != 0
Temp == 0
Temp != 0
None of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
27. Consider the following iterative implementation used to reverse a string:Which of the following lines should be inserted to complete thebelow code?
I > j
I < len
J > 0
I < j
28. Consider the following iterative solution to find the sum of first n natural numbers:Which of the following lines completes thebelow code?
Sm = i
Sm += i
I = sm
I += sm
29. Consider the following recursive implementation of linear search on a linked list:Which of the following lines should be inserted to complete the below code?
1
0
Linear_search(temp, value)
Linear_search(temp->next, value)
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
30. Consider the following recursive implementation of linear search:Which of the following recursive calls should be added to complete the below code?
Recursive_search_num(arr, num+1, idx, len),
Recursive_search_num(arr, num, idx, len),
Recursive_search_num(arr, num, idx+1, len),
Recursive_search_num(arr, num+1, idx+1, len),
Answer & Solution
No Solution for this Answer..! Report or Discus this Question