Question

In: Computer Science

The runtime of a program is proportional to n1.5 where n is the input size.  For input...

The runtime of a program is proportional to n1.5 where n is the input size.  For input size 100 the runtime is 51 ms.  What is the new runtime when the input size is quadrupled?

Solutions

Expert Solution

I have tried to make the solution as simple as possible

If you have any doubts, feel free to ask in comments.

Please give this answer a like, or upvote. This will be very helpful for me.

=========================================================

Answer :

Runtime = 408 ms

=========================================================

Explanation:

Runtimes means the time taken by a program to run completely.

If a program has Runtime of 10ms , it means that it takes 10 ms for this program to be run completely.

Input is processed by program while its running. If the size or amount of input increases , the runtimes also increases in most cases.

Here in the question it is given : 'runtime of a program is propotional to  n1.5 '

So,     ∝    ,  where is Runtime.

we can write this as , = k (    ) , where k is a constant.

So, k = /   n1.5

It is given in the question that when input size is 100 , the runtime is 51ms

So,    = k (    )

=> 51 = k ()

=> k = 51/ ()

It is asked in the question that if runtime is quadrupled, whats new runtime.

So, n = 100*4 = 400.

   = k   (    )

= k ( )

   = 51/ () * ( )

    = 51/1000 * 8000

   = 408 ms

===================================================


Related Solutions

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...
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 Do not change anything in the test file. CPP File: #include #include #include #include using namespace std; vector> findAnagrams(const vector& dict); vector> findAnagrams(const vector& dict) { // Your code here... } Test File: #include #include #include #include using namespace std; vector> findAnagrams(const vector& dict); int main() { vector word_list...
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,...
Write a Java program to create an array of a specific size (which is an input...
Write a Java program to create an array of a specific size (which is an input from the user) and fill it with random numbers between 1 and 100. Then sort the array and count how many of these numbers are originally at sorted position. Display that original array, the sorted array, and the count (number of elements originally at sorted position).
Write a program in C or C++ that takes a number series of size n (n...
Write a program in C or C++ that takes a number series of size n (n integers) as input from the user, push all the numbers to the stack, and reverse the stack using recursion. Please note that this is not simply popping and printing the numbers, but the program should manipulate the stack to have the numbers stored in reverse order. In addition to the provided header file, the students can use the following function to print the content...
Consider the following program specification: Input: An integer n > 0 and an array A[0..(n –...
Consider the following program specification: Input: An integer n > 0 and an array A[0..(n – 1)] of n integers. Output: The largest index b such that A[b] is the largest value in A[0..(n – 1)]. For example, if n = 10 and A = [ 4, 8, 1, 3, 8, 5, 4, 7, 1, 2 ] (so A[0] = 4, A[1] = 8, etc.), then the program would return 4, since the largest value in A is 8 and...
For the following program segments, write a program that shows the estimated runtime for each piece....
For the following program segments, write a program that shows the estimated runtime for each piece. Run it on your computer when n=1, 10, 100, 1000, 10000, 100000, 1000000 for ten times each so that you can observe the differences in performance among these segments. Segment1:        for (sum=0, i=1; i<=n; i++)                         sum = sum + i; Segment2:        for (sum=0, i=1; i<=n; i++)                                                 for (j=1; j<=i; j++)                                                             sum++; Segment3:        sum= n * (n+1)/2
Theorem 5.1 Let n measure the size of the input for a certain task, and suppose...
Theorem 5.1 Let n measure the size of the input for a certain task, and suppose that any algorithm that solves this task must distinguish between f (n) different pos- sibilities. If an algorithm is based on an operation X that has m different outcomes, then the worst-case number of X operations this algorithm performs must be at least logm(f(n)). Consider the task of selecting a person at random from a group of n people by repeatedly rolling a single...
Write a program to do the following. • Input an integer n. • Create a BST...
Write a program to do the following. • Input an integer n. • Create a BST S inserting the keys 1, 2, . . . , n in that order, which will result in a completely-skewed tree. • Measure the time to search for n + 1 in S. • Display the time taken for search. /** * Exception class for access in empty containers * such as stacks, queues, and priority queues. * @author Mark Allen Weiss */ public...
Write a program to do the following. • Input an integer n. • Create a BST...
Write a program to do the following. • Input an integer n. • Create a BST 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT