- Computer Science Engineering (CSE)
- Design and Analysis of Algorithms
- What is the least time in which we can r...

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) |

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. |

View all MCQs in:
Design and Analysis of Algorithms

- Recursive program to raise an integer x to power y uses which of the following algorithm?
- A complete bipartite graph is a one in which each vertex in set X has an edge with set Y. Let n be the total number of vertices. For maximum number of edges, the total number of vertices hat should be present on set X is?
- If GCD of two number is 8 and LCM is 144, then what is the second number if first number is 72?
- You are given n dice each having f faces. You have to find the number of ways in which a sum of S can be achieved. This is the dice throw problem. Which of the following methods can be used to solve the dice throw problem?
- What is the advantage of iterative code for finding power of number over recursive code?
- Recursive approach to find power of a number is preferred over iterative approach.
- In what time can the Hamiltonian path problem can be solved using dynamic programming?
- Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number?
- You are given infinite coins of N denominations v1, v2, v3,…..,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the time complexity of a dynamic programming implementation used to solve the coin change problem?
- For every non-empty string, the length of the longest palindromic subsequence is at least one.

Login to Continue

It will take less than 2 minutes

Report MCQ