GATE Computer ScienceModerateGATE CS (PYQ pattern)
The 8-bit binary-reflected Gray code of x is g(x) = x XOR (x >> 1). For how many of the 256 values of x does g(x) contain exactly two 1 bits?
- A. 56
- B. 28
- C. 21
- D. 8
Correct answer: B. 28
Bit i of g(x) is 1 exactly where bits i and i+1 of x differ (with a 0 assumed above the MSB). So the weight of g(x) is the number of 0/1 boundaries when x is read with a leading 0. Exactly two boundaries means x is one solid block of 1s that does not reach bit 0: choose the 2 boundary positions out of 8, C(8,2) = 28.
More Digital Logic questions
- For 8-bit patterns a and b, how many ordered pairs satisfy a > b when both are read as signed two's complement numbers, but a < b when…
- A one-digit BCD adder adds digits a, b (0-9) and a carry-in c (0 or 1). Its 4-bit binary adder gives a carry K and sum Z8Z4Z2Z1, and the…
- Two 8-input priority encoders receive the same inputs I7..I0. Encoder H gives priority to the highest-numbered asserted input, encoder L…
- An 8-input priority encoder (I7 highest priority) outputs the index y (0 to 7) of the highest asserted input. Among the 255 non-zero input…
- What is the minimum number of 2:1 multiplexers needed to realise the three-input majority function MAJ(a, b, c) = ab + bc + ca if the…
- What is the minimum number of 2:1 multiplexers needed to realise a ⊕ b ⊕ c if the constants 0, 1 and the inputs a, b, c are available but…