Data Structure Questions and Answers-Kadane’s Algorithm

DOWNLOAD FREE PDF <<CLICK HERE>>

Data Structure Questions and Answers-Kadane's Algorithm

Congratulations - you have completed Data Structure Questions and Answers-Kadane's Algorithm.

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]
Kadane's algorithm is used to find .....
A
Longest increasing subsequence
B
Longest palindrome subsequence
C
Maximum sub-array sum
D
All of the mentioned
Question 1 Explanation: 
Kadane's algorithm is used to find the maximum sub-array sum for a given array.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Kadane's algorithm uses which of the following techniques?
A
Divide and conquer
B
Dynamic programming
C
Recursion
D
All of the mentioned
Question 2 Explanation: 
Kadane's algorithm uses dynamic programming.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
For which of the following inputs would Kadane's algorithm produce the CORRECT output?
A
{0, 1, 2, 3}
B
{-1, 0, 1}
C
{-1, -2, -3, 0}
D
All of the mentioned
Question 3 Explanation: 
Kadane's algorithm works if the input array contains at least one non-negative element. All the array inputs have at least one non-negative element. So, Kadane's algorithm will produce the right output for all of the mentioned inputs.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
For which of the following inputs would Kadane's algorithm produce a WRONG output?
A
{1, 0, -1}
B
{-1, -2, -3}
C
{1, 2, 3}
D
{0, 0, 0}
Question 4 Explanation: 
Kadane's algorithm doesn't work for all negative numbers. So, the answer is {-1, -2, -3}.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Complete the following code for Kadane's algorithm:

#include<stdio.h> int max....num(int a, int b) { if(a > b) return a; return b; } int kadane....algo(int *arr, int len) {	 int ans, sum, idx; ans =0; sum =0; for(idx =0; idx < len; idx++) { sum = max....num(0, sum + arr[idx]); ans = .....; } return ans; } int main() { int arr[] = {-2, -3, 4, -1, -2, 1, 5, -3}, len=7; int ans = kadane....algo(arr, len); printf("%d", ans); return 0; }
A
max....num(sum, sum + arr[idx])
B
sum
C
sum + arr[idx].
D
max....num(sum, ans)
Question 5 Explanation: 
The maximum of sum and ans, is stored in ans. So, the answer is max....num(sum, ans).

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>>