Perform the following to the algorithm below: - - Express T(n) as a function of n...
What is the time-complexity of the algorithm abc? Procedure abc(n: integer) s := 0 i :=1 while i ≤ n s := s+1 i := 2*i return s consider the following algorithm: Procedure foo(n: integer) m := 1 for i := 1 to n for j :=1 to i2m:=m*1 return m c.) Find a formula that describes the number of operations the algorithm foo takes for every input n? d.)Express the running time complexity of foo using big-O/big-
(V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a list of n integers) for i = 2 to n do c= j=i-1 while (j > 0) do if ra; then break end if 4j+1 = a; j= j-1 end while j+1 = 1 end for 14: return 0.02. 1, 15: end procedure Answer the following questions: (1) Run the algorithm with input (41, 02, 03, 04) = (3, 0, 1,6). Record the values...
Discrete Math Give a big-Theta estimate for the number of additions in the following algorithm a) procedure f (n: integer) bar = 0; for i = 1 to n^3 for j = 1 to n^2 bar = bar + i + j return bar b) Consider the procedure T given below. procedure T (n: positive integer) if n = 1 return 2 for i = 1 to n^3 x = x + x + x return T(/4) + T(/4) +...
ALGORITHM X(A[0..n - 1]) // Input: A contains n real numbers for it 0 to n - 2 do for jt i +1 to n - 1 do if Aj] > A[i] swap A[i] and A[j] 1. What does this algorithm compute? 2. What is the basic operation? 3. How many times is the basic operation executed? 4. What is the efficiency class of this algorithm?
Show that the number of multiplications used in this algorithm is Consider the following algorithm: procedure multiplications(n: positive integer) for i := 1 to n for j:-1 to i t_2.t return t O (n2) 7l
[Recursive Cost] [ALGORITHM] Improving Efficiency PLEASE explain in DETAIL the following question in detail. The algorithm is also given below. Thank You! 1.a) Define recursively the worst case cost Kn of the Knapsack function for n items. Remember that you need to provide both the base case and the recurrence relation. Also do not forget to include the cost of the function Worth in your cost. Justify your answer (i.e. explain what each component of the formula represents). [5points] 1.b) Use...
[10 marks] consider the following pseudocode: p := 0 x := 2fori:= 2ton p := (p + i ) * x a) How many addition(s) and multiplication(s) are performed by the above pseudocode?b) Express the time-complexity of the pseudocode using the big-Θ notation.) Trace the algorithm, below, then answer (c) and (d): Procedure xyz(n: integer) s := 0, for i:= 1 to n, for j:= 1to i, s:= s+ j*(i− j+ 1) return s c) What is the time-complexity for...
Determine the output of each algorithm below the number of assignment operations in each (show work) the number of print operations in each (show work) the complexity of each algorithm in terms of Big O notation (show work) 2. Let n be a given positive integer, and let myList be a three-dimensional array with capacity n for each dimension. for each index i from 1 to n do { for each index j from 1 to n/2 do { for...
Let T(n) be the running time of function foo. Find the equation of T(n) and find the complexity of T(n) using big-O notation. def foo(L): s = 0 for x in L: j = len(L) while j > 1: j = j / 2 s = s + x print(s) return s
2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running time analysis for both best and worst case. 3. Consider the age data of 12 children who are supposed to undergo for vaccination in ascending order of their age. Suggest and apply a sorting technique which can efficiently handle this data. Show all the intermediate steps clearly. Child ID 01 02 03 04 05 06 07 08 09 10 11 12 2. Age 1...