Question

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) = T

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# STAY HOME # STAY SAFE

Ans 2 :

In the given function A(n), for every invocation a loop with n iterations is executed along with a function call of A(n/2).

Therefore, the approximate expression will be T(n) = T(n/2) + n

Ans 3 :

In the given function A(n), for every invocation a loop with n2 iterations is executed along with three function calls of A(n/3).

Therefore, the approximate expression will be T(n) = 3T(n/3) + n2

Ans 4 :

In the given function A(n), for every invocation two function calls of A(n/2) are executed.

Therefore, the approximate expression will be T(n) = 2T(n/2)

Add a comment
Know the answer?
Add Answer to:
Given algorithm A(n): A(n): {for i = 1 ton sum++; A(n/2); } Fill in the appropriate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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): { A(n/4); for i = 1 ton sum++; A(n/4); } Fill in the appropriate expressions in the box provided: T(n) = TO ) + 问题6 T(n) = 4 Tên/3) + n T(n) = "Theta" 2:57 T(n) = 2 Tn/2) + 1 T(n) = "Theta" 098 T(n) = T/n/2) + n T(n) = "Theta" 问题9 T(n) = 3 Tn2) + n T(n) = "Theta"

  • QUESTION 6 Given algorithm A(n): A(n): { An/2); for i = 1 to n sum++; A(n/2);...

    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)...

  • consider this segment of an algorithm: for i := 1 ton n for j:=1 to 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

  • Induction proofs. a. Prove by induction: n sum i^3 = [n^2][(n+1)^2]/4 i=1 Note: sum is intended...

    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)?...

  • 3. Calculate the time complexity of the following algorithm: 1. Initialize sum to 0. I 2....

    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

  • (V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a...

    (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...

  • Consider the following algorithm Poly(A,a) --------------- 1. n = degree of polynomial (with coef A[n],..,A[0]) 2....

    Consider the following algorithm Poly(A,a) --------------- 1. n = degree of polynomial (with coef A[n],..,A[0]) 2. sum = 0 3. for i = n downto 0 4. sum = sum * a +A[i] show all steps!! (a) Determine the running time of the algorithm, your work should explain your answer (b) what is the loop invariant property of the loop in line 3.

  • (1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an...

    (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)....

  • Compare the algorithm below: Algorithm 1 for i= 0 to i = 4 get the num[i]...

    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.

  • 1) Given that F (a, b, c, d) =Σ(0,1, 2, 4, 5, 7), derive the product...

    1) Given that F (a, b, c, d) =Σ(0,1, 2, 4, 5, 7), derive the product of maxterms expression of F and the two standard form expressions of F` for minterms and maxterms. 2). Given the following Boolean Function: F(A, B, C) = AB + B'(A' + C') Determine the canonical form for the SOP (sum of minterms) and POS (sum of maxterms). Also, draw the truth tables showing the minterms and maxterms. 3) Given n Boolean variables, how many...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT