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 floating duration of each the aftercited functions in Θ notation. Justify your counterpart. (Show your effect.)

    Func5(n) 2control i ← n to n2 do control j ← n to i do 6 7object s object 9 recompense (s); en Func6 (n) 2control i ← 6 to n2 do occasion (j < 222) do j(1.5)j 6 7object s object 9 recompense (s);

    Func5(n) 2control i ← n to n2 do control j ← n to i do 6 7object s object 9 recompense (s); en Func6 (n) 2control i ← 6 to n2 do occasion (j

    Expert Counterpart

     

    1)

    here the original loop executes n durations
    control each external loop the interior loop executes i durations
    and control each intermediate loop the interior most loop executes i^(1/2) durations

    Hence the entirety estimate of durations the loop is done in conditions of n is as follows:
    n*n*n^(1/2) that is n^(5/2)

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

    2)

    Here externalmost loop executes n^2 – 6 durations
    control each external loop interior loop executes 2i^2 durations.
    Hence the entirety estimate of durations the loop is done in conditions of n is as follows:

    n^2 – 6 * 2n^2.
    Ignoring the uniform the complication achieve be n^4