6)
It is
theta(n^(1.262))
7)
It is
theta(n)
8)
It is
theta(n)
9)
It is
theta(n^{log_2(3)}) = theta(n^{1.58})
Given algorithm A(n): A(n): { A(n/4); for i = 1 ton sum++; A(n/4); } Fill in...
Given algorithm A(n): A(n): {for i = 1 ton sum++; A(n/2); } Fill in the appropriate expressions in the box provided: T(n) = TO ) + 03 Given algorithm A(n): A(n): { An/3); A(n/3) for i = 1 to n^2 sum++; A(n/3); } Fill in the appropriate expressions in the box provided: T(n) = TO ) + 问题4 Given algorithm A(n): A(n): { A(n/2); SOP ("Hello"); A(n/2); } Fill in the appropriate expressions in the box provided: T(n) = TO
QUESTION 6 Given algorithm A(n): A(n): { An/2); for i = 1 to n sum++; A(n/2); } Fill in the appropriate expressions in the box provided: T(n) = TO QUESTION 7 Given algorithm A(n): A(n): {for i = 1 to n sum++; Ain/2); } Fill in the appropriate expressions in the box provided: T(n) = TO Given algorithm A(n): A(n): { A(n/4); for i = 1 ton sum++; A(n/4); } Fill in the appropriate expressions in the box provided: T(n)...
Induction proofs. a. Prove by induction: n sum i^3 = [n^2][(n+1)^2]/4 i=1 Note: sum is intended to be the summation symbol, and ^ means what follows is an exponent b. Prove by induction: n^2 - n is even for any n >= 1 10 points 6) Given: T(1) = 2 T(N) = T(N-1) + 3, N>1 What would the value of T(10) be? 7) For the problem above, is there a formula I could use that could directly calculate T(N)?...
consider this segment of an algorithm: for i := 1 ton n for j:=1 to n top:=ij+j+10 a. find a function f(n) that counts the number of multiplication and additions performed in this segment. b. Give a big O estimate for the number of additions and multiplications used in the segment
(1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an integer between 1 and n. (2) Suppose Algorithm-1 does f(n) = n**2 + 4n steps in the worst case, and Algorithm-2 does g(n) = 29n + 3 steps in the worst case, for inputs of size n. For what input sizes is Algorithm-1 faster than Algorithm-2 (in the worst case)? (3) Prove or disprove: SUM{i**2} [where i changes from i=1 to i=n] ϵ tetha(n**2)....
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) +...
9. [10 points) Consider the following algorithm: procedure Algorithm(n: positive integer; ddd: distinet integers) for k:=1 to n-1 for 1-1 to n-k print(k, I, di,da...-1,dn) if ds dti then interchange dy and d (a) Assume that this algorithm receives as input the integer n 6 and the input sequence 하하하하하하, Miss ^-ruteae rehen i12|3141516 Fill out the table below: ds ds (b) Assume that the algorithm receives the same input values as in part a). Once the algorithm finishes, what...
Compare the algorithm below: Algorithm 1 for i= 0 to i = 4 get the num[i] sum = sum + num[i] Average = sum / 5 Print sum Print average Algorithm 2 for i= 0 to i = 4 get the num[i] for i= 0 to i = 4 sum = sum + num[i] Average = sum / 5 Print sum Print average Calculate the complexity of the algorithm. Choose the most efficient algorithm, explain your choice.
3. Calculate the time complexity of the following algorithm: 1. Initialize sum to 0. I 2. Input the value of n. 3. While i = 0 to n-1 do a. sum=sumti; ; b. Increment i
Algorithm MyAlgorithm (A,B) Input: Arrays A and B each storing n >= 1 integers. Output: What is the output? (Refer to part b below) Start: count = 0 C = 10 for i = 0 to C do { sum = 0 for j = 0 to n-1 do { sum = sum + A[0] for k = 1 to j do sum = sum + A[k] } if B[i] == sum then count = count + 1 } return...