## Help authour, Buy PDF Ebook
>>>**Click Here**<<<

## Data Structure Questions and Answers-Kadane's Algorithm

## Click on any option to know the CORRECT ANSWERS

Question 1 |

Kadane's algorithm is used to find .....

Longest increasing subsequence | |

Longest palindrome subsequence | |

Maximum sub-array sum | |

All of the mentioned |

**Visual arts Questions answers**

Question 1 Explanation:

Kadane's algorithm is used to find the maximum sub-array sum for a given array.

Question 2 |

Kadane's algorithm uses which of the following techniques?

Divide and conquer | |

Dynamic programming | |

Recursion | |

All of the mentioned |

**Bank exam Questions answers**

Question 2 Explanation:

Kadane's algorithm uses dynamic programming.

Question 3 |

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 |

**Bank exam Questions answers**

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 |

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

**UPSC test Questions answers**

Question 4 Explanation:

Kadane's algorithm doesn't work for all negative numbers. So, the answer is {-1, -2, -3}.

Question 5 |

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

**EVS Questions answers**

Question 5 Explanation:

The maximum of sum and ans, is stored in ans. So, the answer is max....num(sum, ans).

There are 5 questions to complete.