1. Math
  2. Advanced Math
  3. suppose we have 2 algorithms that solve the same problem...

Question: suppose we have 2 algorithms that solve the same problem...

Question details

Suppose we have 2 algorithms that solve the same problem, alg1 and alg2, both of which take as input a natural number n and produce the same output. We’re going to consider the number of ‘steps’ required to solve the problem taken by each algorithm. alg1 solves the problem in 3 · 2^n ‘steps’ alg2 solves the problem in 20 · n^2 ‘steps’ For small values of n, alg1 solves the problem in fewer steps than alg2, but the running time of alg1 grows faster than the running time of alg2. Find the smallest natural number n such that alg2 solves the problem in fewer steps than alg1. (Hint: Try to find a range that contains the required n, and then think of a way to efficiently search that range for the required n).

Plugging in numbers is not an accepted method it must be explain in a more methodical manner involving algebra.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution