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

Longest increasing subsequence | |

Longest palindrome subsequence | |

Maximum sub-array sum | |

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?

Divide and conquer | |

Dynamic programming | |

Recursion | |

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?

{0, 1, 2, 3} | |

{-1, 0, 1} | |

{-1, -2, -3, 0} | |

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?

{1, 0, -1} | |

{-1, -2, -3} | |

{1, 2, 3} | |

{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; }

max....num(sum, sum + arr[idx]) | |

sum | |

sum + arr[idx]. | |

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.

There are 5 questions to complete.