Question

A program takes time T(n) = k2n  where k is some constant and n is the input...

A program takes time T(n) = k2n  where k is some constant and n is the input size. The program is run twice on the same computer (so k is the same in both cases). The first run is with n = 4 and the time taken is 20 ms. The second run is with n = 10. What is the time taken for the second run, in milliseconds? (Type in just the number; don't type "ms" at the end.)

Homework Answers

Answer #1

Solution:

Given,

=>T(n) = k2^n where k is constant and n is input size

=>T(4) = 20 ms

The answer will be "1280"

Explanation:

Finding value of constant k:

=>We know that T(4) = 20 ms

Put n = 4 and T(4) = 20 ms

=>20 = k*2^4

=>20 = k*16

=>k = 5/4

Finding value of T(10):

Put n = 10

=>T(10) = k*2^10

=>T(10) = (5/4)*2^10 ms

=>T(10) = 5*2^8 ms

=>T(10) = 5*256 ms

=>T(10) = 1280 ms

I have explained each and every part with the help of statements attached to the answer above.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Suppose the runtime of a computer program is proportional to n(logn)2. For input size 28 the...
Suppose the runtime of a computer program is proportional to n(logn)2. For input size 28 the runtime is 154 ms. What is the new runtime in ms when the input size is squared? (Type just the number, not "ms")
A program has runtime proportional to (log n)7 where n is the input size. Suppose we...
A program has runtime proportional to (log n)7 where n is the input size. Suppose we run the program with input size 10 and the runtime is 35 ms. What will the new  runtime be in seconds when we increase the input size to ten billion?.
discrete structures problems 1. A program P takes time proportional to logn where n is the...
discrete structures problems 1. A program P takes time proportional to logn where n is the input size. If the program takes 1 minute to process input of size 1,000,000, how many seconds does it take to process input of size 100? 2. When the best possible algorithm to solve a problem is exponential-time, or in general in nonpolynomial (not in O(np) for any p) we call such a problem ___________________. 3. f(x) is O(x 2) and g(x) is O(x...
An exponential algorithm requires 4^n (four to the power n) steps to solve a problem with...
An exponential algorithm requires 4^n (four to the power n) steps to solve a problem with an input of size n. Suppose it has been found that using today's computer, a direct implementation of that algorithm would be able to handle an input size of 30 in 10 years. If the computer is speeded up by a factor of 100 (with no other changes), what input size can be processed in the same time? Explain your answer. (Hint: speeding up...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
A. The Arrhenius equation shows the relationship between the rate constant k and the temperature T...
A. The Arrhenius equation shows the relationship between the rate constant k and the temperature T in kelvins and is typically written as k=Ae−Ea/RT where R is the gas constant (8.314 J/mol⋅K), A is a constant called the frequency factor, and Ea is the activation energy for the reaction. However, a more practical form of this equation is lnk2k1=EaR(1T1−1T2) which is mathematically equivalent to lnk1k2=EaR(1T2−1T1) where k1 and k2 are the rate constants for a single reaction at two different...
QUESTION 6 1. The time constant in an RC circuit is the time it takes a....
QUESTION 6 1. The time constant in an RC circuit is the time it takes a. so that the current reaches its maximum value b. so that the capacitor is fully charged. C. in which the current decreased 37% of its initial value. d. so that the current drops to zero. QUESTION 7 1. A charged particle is fired at a speed of 5.2x10 ^ 4 m / s at an angle of 35 degrees to a magnetic field of...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
For this assignment you need to write a parallel program in C++ using OpenMP for vector...
For this assignment you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is: #pragma...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT