GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Computing x¹²⁷ by multiplication, where each step multiplies two powers already computed (squarings count as multiplications), what is the minimum number of multiplications needed (the length of a shortest addition chain for 127)?

  1. A. 12
  2. B. 11
  3. C. 13
  4. D. 10

Correct answer: D. 10

The binary method needs 6 squarings + 6 multiplications = 12. A shorter chain exists: 1, 2, 4, 8, 16, 32, 40, 42, 84, 126, 127 (10 steps), and an exhaustive search shows 9 steps are impossible. So the minimum is 10.

More Algorithms questions

Exams that ask this topic