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 WORST case?
Show all steps and calculations please.
`Hey,
Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
Given CPU has 10^8 instruction/sec
So,
n=10^8 has time 1 sec
So, for n=10^4 for algo A1
1 = 4(10^8)^2 + 2*(10^8) + 6
T = 4(10^4)^2 + 2*(10^4) + 6
So,
T=(4*(10^4)^2 + 2*(10^4) + 6)/(4*(10^8)^2 + 2*(10^8) + 6)
So,
Time taken is ~10^-8 sec
For n=10^6
T=(4*(10^6)^2+2*(10^6)+6)/(4*(10^8)^2+2*(10^8)+6)
T=10^-4 sec
For n=10^12
T=(4*(10^12)^2+2*(10^12)+6)/(4*(10^8)^2+2*(10^8)+6)
T=10^8 sec
For Algo 2
For n=10^4
T=(2*10^4*log(10^4)+10)/(2*10^8*log(10^8)+10)=5*10^-5 sec
For n=10^6
T=(2*10^6*log(10^6)+10)/(2*10^8*log(10^8)+10)=0.0075 sec
For n=10^12
T=(2*10^12*log(10^12)+10)/(2*10^8*log(10^8)+10)=1.5*10^4 sec
Kindly revert for any queries
Thanks.
Assume that algorithm A1's running time roughly equals to T1(n) = 4n^2 + 2n + 6...
Suppose that we have two algorithms A1 and A2 for solving the same problem. Let T1(n) be the worst-case time complexity of A1 and T2(n) be the worst-case time complexity of A2. We know that: T(1)=1 T1(n)=15*T1(n/2)+n^2, n>1 T2(1)=1 T2(n)=80*T2(n/3)+20n^3,n>1 a. Use the master method to decide T1(n) b. Use the master method to decide T2(n) c. Which algorithms is more efficient? Why?
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 ?
Give an algorithm with the following properties. • Worst case running time of O(n 2 log(n)). • Average running time of Θ(n). • Best case running time of Ω(1).
Given the following algorithm: Algorithnm Input: a1, a2,...,an, a sequence of numbers n, the length of the sequence x, a number Output: ?? i:- 1 While (x2 # a, and i < n) i+1 End-while If (x- - a) Return(i) Return(-1) 3, -1, 2,9, 36,-7, 6,4 a) What is the correct output of the Algorithm with the following input: a1, a2,..an b) What is the asymptotic worst-case time complexity of the Algorithm? Algorithnm Input: a1, a2,...,an, a sequence of numbers...
What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...
What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...
1. (10 points) Write an efficient iterative (i.e., loop-based) function Fibonnaci(n) that returns the nth Fibonnaci number. By definition Fibonnaci(0) is 1, Fibonnaci(1) is 1, Fibonnaci(2) is 2, Fibonnaci(3) is 3, Fibonnaci(4) is 5, and so on. Your function may only use a constant amount of memory (i.e. no auxiliary array). Argue that the running time of the function is Θ(n), i.e. the function is linear in n. 2. (10 points) Order the following functions by growth rate: N, \N,...
Question 1: Complexity Take a look at the following algorithm written in pseudocode: procedure mystery(a1, a2, …, an: integer) i := 1 while (i < n and ai ≤ ai+1) i := i + 1 if i == n then print “Yes!” else print “No!” What property of the input sequence {an} does this algorithm test? What is the computational complexity of this algorithm, i.e., the number of comparisons being computed as a function of the input size n? Provide...
JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...