GATE Computer ScienceHardGATE CS (PYQ pattern)
What is the maximum possible sum of a non-empty contiguous circular subarray of A = [6, −4, −7, 5, 3, −2, 8, −6, 4, −1] (the array is circular, so a subarray may wrap from the end to the start)?
- A. 14
- B. 20
- C. 12
- D. 17
Correct answer: D. 17
Kadane gives 14 for the ordinary best subarray (5, 3, −2, 8). A wrapping subarray equals total − (minimum subarray) = 6 − (−11) = 17, achieved by the wrapping window 5, 3, −2, 8, −6, 4, −1, 6; brute force over all circular windows confirms 17.
More Algorithms questions
- A 6 × 6 grid is given row by row, where # is a blocked cell: row1 "....#.", row2 "..#...", row3 ".#..#.", row4 "....#.", row5 "#....."…
- Twelve meetings occupy CLOSED time intervals [1,5], [2,6], [5,9], [6,7], [4,8], [7,11], [8,12], [3,10], [9,13], [10,14], [12,15], [13,16]…
- The length of the longest bitonic subsequence (strictly increasing and then strictly decreasing; either part may be empty-length-1) of [4…
- Four greedy rules are proposed for choosing the maximum number of mutually non-overlapping activities: I. repeatedly choose the activity…
- Which of the following statements about the 0/1 knapsack problem is/are correct? I. The O(nW) dynamic programme is polynomial in n and in…
- Six tasks have (processing time, deadline): (3,6), (2,8), (4,9), (1,5), (5,15), (2,10). They run one after another on a single machine…