πŸ“Š Design and Analysis of Algorithms
Q. What is the least time in which we can raise a number x to power y?
  • (A) o(x)
  • (B) o(y)
  • (C) o(log x)
  • (D) o(log y)
πŸ’¬ Discuss
βœ… Correct Answer: (D) o(log y)

Explanation: we can optimize the code for finding power of a number by calculating x raised to power y/2 only once and using it depending on whether y is even or odd.


Explanation by: Mr. Dubey
we can optimize the code for finding power of a number by calculating x raised to power y/2 only once and using it depending on whether y is even or odd.

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
511
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
95%
Success Rate