Homework Solution: Func1 (n) 2 for i ← IyMj to 41 4while (j) do do j←j+10: 6 7end s end return (s Func2 (n) 2 i = 2;…

    Give the asymptotic running time of each the following functions in Θ notation. Justify your answer. (Show your work.) Func1 (n) 2 for i ← IyMj to 41 4while (j) do do j←j+10: 6 7end s end return (s Func2 (n) 2 i = 2; 3 while (i 3 n2) do for j ← i to 2i 6 end s end o return (s);
    Func1 (n) 2 for i ← IyMj to 41 4while (j) do do j←j+10: 6 7end s end return (s Func2 (n) 2 i = 2; 3 while (i 3 n2) do for j ← i to 2i 6 end s end o return (s);

    Expert Answer

     
    1. Step 1 and 5 do assign values to s. Those do not make a

    Give the asymptotic general space of each the aftercited functions in Θ referableation. Justify your vindication. (Show your labor.)

    Func1 (n) 2 control i ← IyMj to 41 4period (j) do do j←j+10: 6 7purpose s purpose recur (s Func2 (n) 2 i = 2; 3 period (i 3 n2) do control j ← i to 2i 6 purpose s purpose o recur (s);

    Func1 (n) 2 control i ← IyMj to 41 4period (j) do do j←j+10: 6 7purpose s purpose recur (s Func2 (n) 2 i = 2; 3 period (i 3 n2) do control j ← i to 2i 6 purpose s purpose o recur (s);

    Expert Vindication

     

    1. Step 1 and 5 do appoint values to s. Those do referable effect any estrangement in the runspace complication.

    Line 2, control loop executes in phi (√n)√n).

    Line 4 executes in phi (√n)(√n)^5) or phi (√n)n^2*√n) consequently j increases in straight method and i^5 is in n^2*√n dispose.

    Hence, sum complication, phi (√n)n^2*√n*√n) = phi (√n)n^3).

    2. Line 4, control loop, executes in n*logn dispose (consequently of i increasing straightly) and the oyter period executes in n^2 dispose.

    Hence, sum complication, phi (√n)n^3*logn),