GATE Computer ScienceHardGATE CS (PYQ pattern)
The array [12, 7, 9, 14, 5, 11, 8, 10, 6] must be split into 3 contiguous parts so that the largest part sum is as small as possible. What is that minimum possible largest sum?
- A. 28
- B. 30
- C. 27
- D. 33
Correct answer: B. 30
Binary search on the answer between max = 14 and total = 82, with the greedy feasibility test (start a new part when the sum would exceed the limit), gives 30: [12,7,9], [14,5,11], [8,10,6] are 28, 30, 24. The average 27.3 is only a lower bound.
More Algorithms questions
- Coupons of 6 equally likely types are drawn with replacement. What is the expected number of draws until 4 different types have been seen?
- Counting sort (stable, processing the input from right to left with cumulative counts) is applied to a = [4, 2, 2, 8, 3, 3, 1, 4, 2]. At…
- LSD radix sort (decimal digits, stable counting sort on each digit, least significant first) is applied to [329, 457, 657, 839, 436, 720…
- A shell sort pass with gap 5 (a gapped insertion sort) is applied to [23, 12, 45, 3, 67, 8, 34, 19, 56, 2, 41, 28]. The cost of the pass…
- The array [14, 5, 21, 9, 30, 7, 18, 2, 26, 11] is made into a max-heap, giving [30, 26, 21, 14, 11, 7, 18, 2, 9, 5]. Heapsort then…
- In how many ways can 30 be written as a sum of ODD positive integers, where order does not matter and parts may repeat?