Skip to content
GATEiit

GATE CSE 2019 Q35: Maximum subarray sum of a 14-element sequence

Syllabus topic: Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Question

Consider a sequence of 14 elements: A=[−5,−10,6,3,−1,−2,13,4,−9,−1,4,12,−3,0]. The subsequence sum S(i,j)=∑k=ijA[k]. Determine the maximum of S(i,j), where 0≤i≤j<14. (Divide and conquer approach may be used.)

Answer: ________.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 29 (official GATE 2019 final answer key)

Concept used: Maximum contiguous subarray sum, solvable by Kadane's algorithm or divide and conquer.

Concept notes

Loading notes…

First step: Scan left to right keeping a running sum, resetting it to 0 whenever it goes negative, and track the best value seen.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Algorithm design techniques: greedy, dynamic programming and divide-and-conquer

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key