Counting set bits - 0

03  20, 2008

You are given a computer with an n-bit machine word, which supports the standard bitwise operations: AND, OR, NOT, XOR, LEFT SHIFT, and RIGHT SHIFT. Given a machine word W, what is the smallest number of bitwise operations you need to perform to determine the number of set bits in W? You can assume you have arbitrarily many registers to use and COPY operations are not counted. The result has to be presented in the form of an integer represented in a machine word. Communicated by teacher David Karger.

Desire to speak? ↓