## Question 1 What will be the output if $n = 6$? ### Options 1. $[0, 1, 1, 2, 1, 2, 2]$ Correct Starting from $0$, we have:
* $0 = 0000 \rightarrow$ Count of $1$s $= 0$ * $1 = 0010 \rightarrow$ Count of $1$s $= 1$ * $2 = 0010 \rightarrow$ Count of $1$s $= 1$ * $3 = 0011 \rightarrow$ Count of $1$s $= 2$ * $4 = 0100 \rightarrow$ Count of $1$s $= 1$ * $5 = 0101 \rightarrow$ Count of $1$s $= 2$ * $6 = 0110 \rightarrow$ Count of $1$s $= 2$ So the final array would be $[0, 1, 1, 2, 1, 2, 2]$. ---------------------------- 2. $[0, 1, 1, 2, 1, 1, 2]$ Incorrect ---------------------------- 3. $[0, 1, 2, 2, 1, 2, 1]$ Incorrect ---------------------------- --------------------------------------------- ## Question 2 (**True** or **False**). The number of $1$ bits in the binary representation of even numbers is always equal to the number of $1$ bits in half of the given number? ### Options 1. True Correct For example, the binary representation of $16$ contains only one $1$ bit. Half of $16$, that is, $8$, also contains only one $1$ bit in its binary representation. ---------------------------- 2. False Incorrect ---------------------------- --------------------------------------------- ## Question 3 What will be the output if $n = 8$? ### Options 1. $[0, 1, 1, 2, 1, 2, 2, 2, 1]$ Incorrect ---------------------------- 2. $[0, 1, 1, 2, 1, 2, 2, 3, 1]$ Correct Starting from $0$, we have:
* $0 = 0000 \rightarrow$ Count of $1$s $= 0$ * $1 = 0010 \rightarrow$ Count of $1$s $= 1$ * $2 = 0010 \rightarrow$ Count of $1$s $= 1$ * $3 = 0011 \rightarrow$ Count of $1$s $= 2$ * $4 = 0100 \rightarrow$ Count of $1$s $= 1$ * $5 = 0101 \rightarrow$ Count of $1$s $= 2$ * $6 = 0110 \rightarrow$ Count of $1$s $= 2$ * $7 = 0111 \rightarrow$ Count of $1$s $= 3$ * $8 = 1000 \rightarrow$ Count of $1$s $= 1$ So the final array would be $[0, 1, 1, 2, 1, 2, 2, 3, 1]$. ---------------------------- 3. $[0, 1, 1, 2, 1, 2, 2, 3, 2]$ Incorrect ---------------------------- --------------------------------------------- ## Question 4 What will be the output if $n = 10$? ### Options 1. $[0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2]$ Correct Starting from $0$, we have:
* $0 = 0000 \rightarrow$ Count of $1$s $= 0$ * $1 = 0010 \rightarrow$ Count of $1$s $= 1$ * $2 = 0010 \rightarrow$ Count of $1$s $= 1$ * $3 = 0011 \rightarrow$ Count of $1$s $= 2$ * $4 = 0100 \rightarrow$ Count of $1$s $= 1$ * $5 = 0101 \rightarrow$ Count of $1$s $= 2$ * $6 = 0110 \rightarrow$ Count of $1$s $= 2$ * $7 = 0111 \rightarrow$ Count of $1$s $= 3$ * $8 = 1000 \rightarrow$ Count of $1$s $= 1$ * $9 = 1001 \rightarrow$ Count of $1$s $= 2$ * $10 = 1010 \rightarrow$ Count of $1$s $= 2$ So the final array would be $[0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2]$. ---------------------------- 2. $[0, 1, 1, 2, 1, 2, 2, 2, 1, 3, 1]$ Incorrect ---------------------------- 3. $[0, 1, 1, 2, 1, 2, 2, 2, 1, 3, 2]$ Incorrect ---------------------------- ---------------------------------------------