GATE Computer ScienceVery hardGATE CS (PYQ pattern)

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 combinations, for how many does y equal the number of asserted inputs?

  1. A. 8
  2. B. 28
  3. C. 35
  4. D. 56

Correct answer: B. 28

If the highest asserted input is I_k, the number of asserted inputs is 1 + (number among the k lower inputs). It equals k when exactly k − 1 of the k lower inputs are asserted: C(k, k−1) = k ways. For k = 0 the count would be 1 ≠ 0, so summing k = 1..7 gives 1 + 2 + ... + 7 = 28.

More Digital Logic questions

Exams that ask this topic