Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Algorithms? HOW TO FIND MINlMUM SUB ARRAY? Explain please A problem similar to f

ID: 3782435 • Letter: A

Question

Algorithms? HOW TO FIND MINlMUM SUB ARRAY? Explain please

A problem similar to finding the maximum-subarray is to find the minimum-subarray Given you have an algorithm to find the maximum-subarray, how would you change it to find the minium-subarray? The minimum-subarray problem cannot be reduced to the maximum-subarray problem. Multiply all numbers in the input by negative 1 to create a new input Find the maximum sub array on this input and multiply by all numbers by negative 1 again before returning it An empty array will always be the minium-subarray and therefore for any input we may just return an empty array.

Explanation / Answer

Option second is correct

Change the sign of all the elements and find maximum sub array. This way all positive will be negative and negative values will become positive and thus maximum sum will be minimum sum after negating back.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote