GATE Computer ScienceHardGATE CS (PYQ pattern)
How many non-empty subsets of {3, 5, 6, 7, 9, 11, 13, 14} have an element sum divisible by 10?
- A. 26
- B. 24
- C. 25
- D. 22
Correct answer: C. 25
Counting subsets by sum modulo 10 with a DP (or listing all 256 subsets) gives 26 subsets including the empty one, i.e. 25 non-empty ones (e.g. {3, 7}, {6, 14}, {5, 6, 9}, …, sums 10, 20, 30, 40, 50, 60). Counting the empty set gives 26; 256/10 ≈ 25.6 is only a heuristic.
More Algorithms questions
- A cyclic binary string of length 12 is written around a circle, so position 12 is followed by position 1. How many of the 2¹² strings…
- 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…
- 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…