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...
Write a program to do the following. • Input an integer n. • Create a BinarySearchTree...
Write a program to do the following. • Input an integer n. • Create a BinarySearchTree B containing the same items, but inserting them in an order that will yield the tree balanced. The following algorithm, known as pre-order traversal, gives you a strategy to produce that sequence. seq(low, high, T){ if (low <= high){ mid = (low+high)/2 T.insert(mid) seq(low, mid-1, T) seq(mid+1, high, T) } } • Measure the time to search for n + 1 in B. •...
Write a program (O(n), where n is the number of words) that takes as input a...
Write a program (O(n), where n is the number of words) that takes as input a set of words and returns groups of anagrams for those words. Complete your code here - For example, if the list is "debitcard", "elvis", "silent", "badcredit", "lives", "freedom", "listen", "levis", the output should be silent listen debitcard badcredit elvis lives levis Note that freedom has no anagram, and hence is not printed. ///////////////////////////////////////////////$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% anagram.cpp #include <iostream> #include <unordered_map> #include <vector> #include <algorithm> using namespace...
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...
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads...
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads in a sequence of strings from standard input using StdIn.readString() , and prints out exactly k of them, uniformly at random. Each item from the sequence can be printed out at most once. You may assume that 0 k N , where N is the number of string on standard input. The running time of the program must be linear in the size 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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT