Data Structure Questions and Answers-Largest and Smallest Number in an Array using Recursion

DOWNLOAD FREE PDF <<CLICK HERE>>

Data Structure Questions and Answers-Largest and Smallest Number in an Array using Recursion

Congratulations - you have completed Data Structure Questions and Answers-Largest and Smallest Number in an Array using Recursion.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%


Your answers are highlighted below.
Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Which of the following methods can be used to find the largest and smallest element in an array?
A
Recursion
B
Iteration
C
Both recursion and iteration
D
None of the mentioned
Question 1 Explanation: 
Both recursion and iteration can be used to find the largest and smallest element in an array.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Consider the following iterative code snippet to find the largest element:

int get....max....element(int *arr, int n) { int i,  max....element = arr[0]; for(i = 1; i < n; i++) if(.....) max....element = arr[i]; return max....element; }

Which of the following lines should be inserted to complete the above code?

A
arr[i] > max....element
B
arr[i] < max....element
C
arr[i] == max....element
D
none of the mentioned
Question 2 Explanation: 
The line "arr[i] > max....element" should be inserted to complete the above code snippet.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Consider the following code snippet to find the smallest element in an array:

int get....min....element(int *arr,  int n) { int i,  min....element = arr[0]; for(i = 1; i < n; i++) if(.....) min....element = arr[i]; return min....element; }

Which of the following lines should be inserted to complete the above code?

A
arr[i] > min....element
B
arr[i] < min....element
C
arr[i] == min....element
D
none of the mentioned
Question 3 Explanation: 
The line "arr[i] < min....element" should be inserted to complete the above code.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the output of the following code?

#include<stdio.h> int get....max....element(int *arr, int n) { int i,  max....element = arr[0]; for(i = 1; i < n; i++) if(arr[i] > max....element) max....element = arr[i]; return max....element; } int get....min....element(int *arr,  int n) { int i,  min....element = arr[0]; for(i = 1; i < n; i++) if(arr[i] < min....element) min....element = arr[i]; return min....element; } int main() { int n = 7,  arr[7] = {5, 2, 4, 7, 8, 1, 3}; int max....element = get....max....element(arr, n); int min....element = get....min....element(arr, n); printf("%d %d", max....element, min....element); return 0; }
A
5 3
B
3 5
C
8 1
D
1 8
Question 4 Explanation: 
The program prints the values of the largest and the smallest elements in the array, which are 8 and 1 respectively.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the output of the following code?

#include<stdio.h> int get....max....element(int *arr, int n) { int i,  max....element = arr[0]; for(i = 1; i < n; i++) if(arr[i] > max....element) max....element = arr[i]; return max....element; } int get....min....element(int *arr,  int n) { int i,  min....element; for(i = 1; i < n; i++) if(arr[i] < min....element) min....element = arr[i]; return min....element; } int main() { int n = 7,  arr[7] = {1, 1, 1, 0, -1, -1, -1}; int max....element = get....max....element(arr, n); int min....element = get....min....element(arr, n); printf("%d %d", max....element, min....element); return 0; }
A
1 -1
B
-1 1
C
1 Garbage value
D
Garbage value -1
Question 5 Explanation: 
Since the min....element variable is not initialised, the get....min....element() function will return a garbage value.

Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 5 questions to complete.

DOWNLOAD FREE PDF <<CLICK HERE>>