complexity of first for loop is n/2 = O(n) times. complexity of second for loop is O(n^2) times. so, work done inside a recursive call is O(n^2) two recursive calls are made of size n/2 so, recurrence relation is T(n) = 2T(n/2) + O(n^2) Answer: O(n2)
float useless(A){ n = A.length; if (n==1) { return A[@]; let A1,A2 be arrays of size...
(a) Let P(B1∩B2)>0, and A1∪A2⊂B1∩B2. Then show that P(A1|B1).P(A2|B2)=P(A1|B2).P(A2|B1). (b) Let A and B1 be independent; similarly, let A and B2 be independent. Show that in this case, A and B1∪B2 are independent if and only if A and B1∩B2 are independent. (c) Given P(A) = 0.42,P(B) = 0.25, and P(A∩B) = 0.17, find (i)P(A∪B) ; (ii)P(A∩Bc) ; (iii)P(Ac∩Bc) ; (iv)P(Ac|Bc).
Consider the following expressions: A1: f = Fw A2: f = Fw sinθ B1: N = W 2 B2: N = W C1: ℓFw sinθ = 2Fw cosθ C2: ℓFw sinθ = ℓ W cosθ C3: ℓFw sinθ = 1 2 ℓ W cosθ, where f: force of friction between the ladder and the ground, Fw: normal force on the ladder due to the wall, θ: anglebetween theladder and theground, N: normal force on the ladder due to the ground,...
C4v E 2C4 C2 2sigmav 2sigmad A1 1 1 1 1 1 z A2 1 1 1 -1 -1 Rz B1 1 -1 1 1 -1 B2 1 -1 1 -1 1 E 2 0 -2 0 0 (x,y) (Rx, Ry) The C4v character table is given above. Prove that the following combinations of irreps are orthogonal. a) B2 E b) A2 B1 c) A1 B2
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.
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...
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...
max{a1, a2, n<3 Show that 1 1 1 7 . 3 (a1a +.an) 3 an 3 a2 3- a1 using definition of convex
2 Double summation Let a1, A2, A3, ... be a sequence of real numbers, and let n > 1 be an integer. Which of the following are always equal? пі пп nn nn « ££« Žia. E£« L« i=1 j=1 i=1 j=1 i= 1 i=1 j=1 j=1 i=j