Question

In: Computer Science

Suppose an algorithm A1 has a runtime T1(n) defined ( in seconds) by the following function...

Suppose an algorithm A1 has a runtime T1(n) defined ( in seconds) by the following function

T1(n) = n3 + 20n + 15

For n = 13, the runtime of the algorithm is 2472 seconds. Let us assume that we have an algorithm A2 with runtime given by T2(n) = n2 + 22n + 14? What will be the lowest value of n for which the runtime of A2 exceeds 2472 seconds?

**Urgently needed**

Solutions

Expert Solution

To find a value of T2(n) = n2 + 22n + 14 in such a way that it exceeds 2472 seconds, following steps are to be done:

Step 1: Take  n2 + 22n + 14 = 2472 and find the value of n. This is to be done as on substituting the value of n the result shouls be more than 2472. So fist find the value of n for which T2(n) = 2472.

so,    n2 + 22n + 14 = 2472

=>  n2 + 22n + 14 - 2472 = 0

=> n2 + 22n -2458 = 0

Now use discriminant method to solve the equation: any equation is of the form ax2 + by +c =0

D = sqroot(b2-4*a*c) = sqroot((22)2 - 4*1*(-2458)) = 101.56 = positive

Hence, value of n exists.

so, n = (-b D) / 2*a

n = (-22 101.56) / 2 *1

on solving n = 39.78 and -61.78

negative value of n is not acceptable. So n = 39.78. To get the lowest n approximate it to 40.

Step 2 :

The value should come out to be more than 2472. so put the value as 40.

So, T2(n) = n2 + 22n + 14 = (40)2 + 22*40 + 14 = 2494.

Answer : Therefore lowest possible value of n =40.


Related Solutions

Find the runtime of this function, where n is an integer. int function(int n) { int...
Find the runtime of this function, where n is an integer. int function(int n) { int a = 0; for (int i = n; i > 0; i--) { for (int j = 0; j < i; j++) { a = a + i + j; } } return a; } Find the runtime of this function, where m and n are two integers. int f(int m, int n) { if (m==1 || n==1) { return 1; } return f(m,...
Suppose the runtime of a computer program is proportional to 2^n where n is the input...
Suppose the runtime of a computer program is proportional to 2^n where n is the input size. When given an input of size 1024, suppose the runtime is 256ms. For what input size would the program have runtime of 1ms? A program takes time proportional to the input size. If the program takes 36 milliseconds for input size 30, how  many milliseconds does it take for input size 10? A program takes time T(n) = k2n  where k is some constant and...
Present an O(n) algorithm that sorts n positive integer numbers a1, a2, . . . ,...
Present an O(n) algorithm that sorts n positive integer numbers a1, a2, . . . , an which are known to be bounded by n 2 (so ai ≤ n 2 , for every i = 1, . . . , n. Use the idea of Radix Sort (discussed in class and presented in Section 8.3 in the textbook). Illustrate your algorithm by showing on paper similar to Fig. 8.3, page 198 in the textbook (make sure you indicate clearly...
Consider the following algorithm, which takes as input a sequence of ?n integers ?1,?2,…,??a1,a2,…,an and produces...
Consider the following algorithm, which takes as input a sequence of ?n integers ?1,?2,…,??a1,a2,…,an and produces as output a matrix ?={???}M={mij} where ???mij is the minim term in the sequence of integers ??,??+1,…,??ai,ai+1,…,aj for ?≥?j≥i and ???=0mij=0 otherwise. for i := 1 to n for j := 1+1 to n for k:= i+1 to j m[i][j] := min(m[i][j], a[k]) end for end for end for return m a.) Show that this algorithm uses ?(?3)O(n3) comparisons to compute the matrix M....
Suppose T1 and T2 are iid Exp(1). What is the probability density function of T1+T2? What...
Suppose T1 and T2 are iid Exp(1). What is the probability density function of T1+T2? What is the probability that T1+T2 ≥ 3?
Write the first four terms of the sequence defined by the recursive formula a1 = 2, an = an − 1 + n.
Write the first four terms of the sequence defined by the recursive formula a1 = 2, an = an − 1 + n.
Suppose that a1-12 and an+1 is a third of the value of an for all n=1,2,3,4,5.......
Suppose that a1-12 and an+1 is a third of the value of an for all n=1,2,3,4,5.... natural numbers. a) find the first foudn terms fo the sequence b) find the formula for all values of the sequence c) compute the exact value of the infinite sum
There are two algorithms that perform a particular task. Algorithm 1 has a complexity function: f(n)...
There are two algorithms that perform a particular task. Algorithm 1 has a complexity function: f(n) = 5n + 50. Algorithm 2 has a complexity function g(n) = n^2 + 10g . (Show your answer) a)Which algorithm is more efficient when n = 5? b) Which algorithm is more efficient when n = 20? c) what are complexity of f(n) and g(n)
3. Suppose that a divide and conquer algorithm for multiplication of n x n matrices is...
3. Suppose that a divide and conquer algorithm for multiplication of n x n matrices is found such that it requires 6 multiplications and 31 additions of n/2 x n/2 submatrices. Write the recurrence for the running time T(n) of this algorithm and find the order of T(n).
What is O(g(n)) for the following method? What sorting algorithm is this? /*Function to sort array...
What is O(g(n)) for the following method? What sorting algorithm is this? /*Function to sort array using ??? sort*/ void sort(int arr[]) { int n = arr.length; for (int i = 1; i < n; ++i) { int key = arr[i]; int j = i - 1; /* Move elements of arr[0..i-1], that are greater than key, to one position ahead of their current position */ while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j];...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT