Homework Solution: Give the asymptotic running time of each the following functions in Θ notation. Justify your…

    Give the asymptotic running time of each the following functions in Θ notation. Justify your answer. (Show your work.) Func5(n) 2for i ← n to n2 do for j ← n to i do 6 7end s end 9 return (s); en Func6 (n) 2for i ← 6 to n2 do while (j < 222) do j(1.5)j 6 7end s end 9 return (s);
    Func5(n) 2for i ← n to n2 do for j ← n to i do 6 7end s end 9 return (s); en Func6 (n) 2for i ← 6 to n2 do while (j

    Expert Answer

     
    1) here the first loop executes n times

    Give the asymptotic vulgar space of each the subjoined functions in Θ notation. Justify your acceptance. (Show your exertion.)

    Func5(n) 2restraint i ← n to n2 do restraint j ← n to i do 6 7object s object 9 retaliate (s); en Func6 (n) 2restraint i ← 6 to n2 do period (j < 222) do j(1.5)j 6 7object s object 9 retaliate (s);

    Func5(n) 2restraint i ← n to n2 do restraint j ← n to i do 6 7object s object 9 retaliate (s); en Func6 (n) 2restraint i ← 6 to n2 do period (j

    Expert Acceptance

     

    1)

    here the controlemost loop executes n spaces
    restraint each external loop the secret loop executes i spaces
    and restraint each average loop the secret most loop executes i^(1/2) spaces

    Hence the entirety reckon of spaces the loop is manufactured in stipulations of n is as follows:
    n*n*n^(1/2) that is n^(5/2)

    Hence the perplexity is O(n^(5/2))

    2)

    Here externalmost loop executes n^2 – 6 spaces
    restraint each external loop secret loop executes 2i^2 spaces.
    Hence the entirety reckon of spaces the loop is manufactured in stipulations of n is as follows:

    n^2 – 6 * 2n^2.
    Ignoring the continuous the perplexity gain be n^4