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).
2. Write a program to do the following: • ask the user to input the size...
2. Write a program to do the following: • ask the user to input the size of an array of integers and allocate space for the array • ask the user to input the integer values for the array and store these values into the array • calculate and display the sum and the average of elements of the array
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...
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...
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
Runtime complexity of Insertion sort and Mergesort algirthms- and analysis with different size of inputs: In...
Runtime complexity of Insertion sort and Mergesort algirthms- and analysis with different size of inputs: In python Implement a method to sort a given array using the merge sort algorithm. Write a driver program to test the merge sort algorithm and insertion sort algorithm for the arrays of varying lengths provided.. Ex: array lenth 100, Array lenth 1000 etc. Compare the execution time of merge sort with insertion sort. Make sure you use the same array to compare the performance....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT