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?
a)b)
c) T1 is more efficient. because n^3.91 is smaller than n^3.99
Suppose that we have two algorithms A1 and A2 for solving the same problem. Let T1(n)...
Suppose we have two algorithms A1 and A2 for solving the same problem. Let T_1(n) be the worst case time complexity of Algorithm A1 and T_2(n) be the worst case time complexity of Algorithm A2. We know that T_1(1) = 1 and T_1(n) = 8 middot T_1(n/2) + 100n^2. We also know that T_2(1) = 1 and T_2(n) = 63 middot T_2(n/4) + 200 middot n^2. Use the master method to decide T_1(n). Follow all the steps as illustrated in...
Consider two algorithms A1 and A2 that have the running times T1(n) and T2(n), respectively. T1(n) = n3 + 3n and T2(n) = 50n2. Use the definition of Ω() to show that T1(n) € Ω(T2(n))
1. Suppose you are given 3 algorithms A1, A2 and A3 solving the same problem. You know that in the worst case the running times are Ti(n) = 101#nº + n, Ta(n) = 10”, TS(n) = 101 nº logo n10 (a) Which algorithm is the fastest for very large inputs? Which algorithm is the slowest for very large inputs? (Justify your answer.) (b) For which problem sizes is Al the best algorithm to use (out of the three)? Answer the...
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...
Analysis of Algorithms Fall 2013 Do any (4) out of the following (5) problems 1. Assume n-3t is a power of 3 fork20. Solve accurately the following recursion. If you cannot find the exact solution, use the big-O notation. Tu) T(n)Tin/3)+2 2. Suppose that you have 2 differeut algorithms to solve a giveu probleen Algorithm A has worst-case time complexity e(n2) and Algorithm B has worst-case time complexity e(nlog n). Which of the following statements are true and which are...
Let n be a positive integer. We sample n numbers a1, a2,..., an from the set {1,...,n} uniformly at random, with replacement. We say that picks i and j with are a match if ai = aj, i < j. What is the expected total number of matches? Use indicators.
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...
2.After analyzing a few algorithms we found the primitive operations done in the algorithms as the following functions of their input sizes n. Find the big O of the algorithms and sort them from the fastest to the showest algorithms. 1. T1(n) = 5n2+ 20n + 15 2. T2(n) = 6n3+ 8n4+100 3. T3(n) = 7log(n) + 4 4. T4(n) = 2n+ 3n2 + 1 5. T5(n) = 5nlog(n) + 3log(n) + 3n 3.In an attempt to print numbers from...
Question 4 (10 marks) When analysing the complexity of algorithms, there are three main approaches: worst case, best case and average case. As an example, consider measuring the complexity of list-merging by counting the number of comparisons used As a test example, assume the following A1: There are two ordered lists, each of length 4, say A2: Neither list contains repeats, so a! < a2 < аз < a4 and bl <b2 < b3 < b4 A3: The lists are...