Try Analyze Following Algorithm Function Foo N N 1 Print Foo N 3 1 N Print B End Foo N 3 E Q23512553

5. Try to analyze the following algorithm. Function Foo(n) if n > 1 then Print A Foo(n/3) for i from 1 to n do IPrint B end Foo(n/3) end a) What is the running time of the function Foo(n)? Give detailed steps to obtain the asymptotic running time in big-Θ notation. b) How many As will be printed by Foo(n)? Give detailed steps to obtain your solution in big-O notation (in terms of n). Solution. Your solution here

Try to analyze the following algorithm. Function Foo(n) if n > 1 then Print ‘A’ Foo(n/3) for i from 1 to n do Print ‘B’ end Foo(n/3) end a) What is the running time of the function Foo(n)? Give detailed steps to obtain the asymptotic running time in big- theta notation. b) How many ‘A’s will be printed by Foo(n)? Give detailed steps to obtain your solution in big- theta notation (in terms of n). Show transcribed image text

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *