Question 1

Solution:

Set A

Untitled

  1. What does the function call f(31, 0) return? Answer: 0
  2. What does the function call f(899, 0) return? Answer: 5
  3. The function computes the number of zeros in the binary representation of the number. Any equivalent way of stating the same should be awarded as well.

Set B

Untitled

  1. What does the function call f(25, 0) return? Answer: 3
  2. What does the function call f(999, 0) return? Answer: 8
  3. The function computes the number of ones in the binary representation of the number. Any equivalent way of stating the same should be awarded as well.

Rubrics