ProgrammingVery hard
Exponentiation by squaring computes x^1000 with how many multiplications at most, counting squarings and the result multiplications?
- A. 9
- B. 6
- C. 15
- D. 20
Correct answer: C. 15
There are 9 squarings (floor of log2 1000 is 9) and one multiplication per set bit, of which 1000 has 6, so 15 in total.
More C Programming questions
- In ASCII, what is 'k' ^ 32 as a character?
- In a 32-bit unsigned int, what is (~0u) >> 28?
- What value does a[i] ^= a[j] leave when i and j refer to the same element?
- Which expression sets bit 31 of an unsigned 32-bit variable x with no undefined behaviour?
- The sequence n ^ (n >> 1) for n = 0, 1, 2, 3 gives what list?
- For positive values below 2^31, which product is guaranteed to fit in a signed 64-bit integer?