Question 11
What does the following recursive function return when called as count_bits(13)?
JAVASCRIPT
int count_bits(int n) {
if (n == 0) return 0;
return (n & 1) + count_bits(n >> 1);
}Detailed Solution
13 in binary is 1101, which has three 1-bits.
✓ Saved