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...
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...
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...
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....
In Liinear-time selection algorithm where the input array of numbers are cut into groups of size...
In Liinear-time selection algorithm where the input array of numbers are cut into groups of size 5. Show that, when the group size is 7, the algorithm still runs in linear time.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT