GATE Computer ScienceVery hardGATE CSE · UGC NET

A 16-bit binary counter starts at 0 and is incremented 1000 times. The cost of an increment is the number of bits that change. What is the total cost?

  1. A. 1988
  2. B. 2000
  3. C. 1994
  4. D. 2004

Correct answer: C. 1994

The total flips for n increments equal 2n − popcount(n) = 2000 − 6 = 1994.

More Algorithms questions

Exams that ask this topic