GATE Computer ScienceVery hardGATE CS (PYQ pattern)
For how many of the 256 eight-bit patterns x does the 8-bit two's complement negation −x (= x' + 1, carry out discarded) contain exactly as many 1 bits as x?
- A. 29
- B. 30
- C. 16
- D. 35
Correct answer: B. 30
Write x = y·1·0^k (lowest 1 at bit k, y the 7 − k bits above it). Then −x = y'·1·0^k, so popcount(x) = p + 1 and popcount(−x) = (7 − k − p) + 1, where p = popcount(y). Equal iff p = (7 − k)/2, so k is odd: k = 1: C(6,3) = 20; k = 3: C(4,2) = 6; k = 5: C(2,1) = 2; k = 7: 1 (x = 10000000). That is 29, plus x = 0 (−0 = 0): 30.
More Digital Logic questions
- A designer has 6 check bits per word. What is the largest number of data bits that can be protected by (i) a single-error-correcting…
- Among the C(16,4) = 1820 four-variable Boolean functions with exactly four minterms, how many have a minimal sum-of-products with exactly…
- Among the C(16,3) = 560 four-variable Boolean functions with exactly three minterms, how many have a minimal sum-of-products that needs…
- Among all C(16,4) = 1820 four-variable functions with exactly four minterms, for how many does the minimal sum-of-products need four…
- How many non-zero three-variable Boolean functions have exactly six prime implicants?
- Of the 16 Boolean functions f(x, y) of two variables, how many are associative, i.e. f(f(x,y),z) = f(x,f(y,z)) for all x, y, z?