Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32. What is input size makes the algorithm run for 14 milliseconds?
Assume F(n) is the function for the run time of an algorithm.
Then, F(n) = c log2n for some constant say c.
F(32) = c log232 = 10
=> 5c = 10, Hence c = 2
Similarly,
F(n) = 2 log2n = 14, Hence log2n = 7
=> n = 27= 128
Therefore, the input size which makes the algorithm run for 14 milliseconds is 128 (N).
Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32....
Suppose that an algorithm has run-time proportional to 2n , where n is the input size. The algorithm takes 1 millisecond to process an array of size 10. How many milliseconds would you expect the algorithm take to process an array of size 20 ?
Computer Algorithm question 8) Give an algorithm for building a heap in O(n) 9) Prove the algorithm given in 8) runs in O(n) time. 10) What is the asymptotic runtime of an algorithm represented by the following recurrence equation? 11) Suppose you have the following priority queue implemented as a (max) heap. What will the heap look like when the max node is removed and the heap is readjusted? Assume on each heapify operation the largest child node is selected...
A certain computer algorithm executes three times as many operations when it is run with an input of size n as when it is run with an input of size n -1 (where n > 1 is an integer). When the algorithm is run with an input of size 1, it executes ten operations. Let sn be the number of operations the algorithm executes when it is run on an input of size n. Find a closed form for s....
Assume that algorithm A1's running time roughly equals to T1(n) = 4n^2 + 2n + 6 and algorithm A2's running time roughly equals to T2(n) = 2n lg(n) + 10 . Suppose that Computer A's cpu runs 10^8 instructions/sec. When the input size equals to 10^4, 10^6, and 10^12 respectively, how long will algorithm A1 take to finish for each input size in the WORST case? How long will algorithm A2 take to finish for each input size in the...
5. (570/470 bonus) Design an algorithm whose input is a list of n points, (xu, ) for isks n. Your algorithm should run in O(n) time and determine whether or not the convex hull of these n points is a triangle. Also explain why your algorithm runs in O(n) time.
Suppose you are given k sorted arrays of size n. Give an algorithm, that runs in O(nk log k)time, that merges them into a single list.
can selection be done in O(n) expected time. if the size of the input is n . If so how does it to be done? Analyse your algorithm
For an O(Nk ) algorithm, where k is a positive integer, an instance of size M takes 32 seconds to run. Suppose you run an instance of size 2M and find that it takes 512 seconds to run. What is the value of k?
Design an Algorithm that tests whether or not 2 input lists of size n have at least 1 element in common. Give formulas for B(n) and W(n) for your algorithm.
Suppose the following is a divide-and-conquer algorithm for some problem. "Make the input of size n into 3 subproblems of sizes n/2 , n/4 , n/8 , respectively with O(n) time; Recursively call on these subproblems; and then combine the results in O(n) time. The recursive call returns when the problems become of size 1 and the time in this case is constant." (a) Let T(n) denote the worst-case running time of this approach on the problem of size n....