Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 2 0 points ) Assume $n$ is a power of $ 6 $ . Assume we are given an algorithm $f ( n )

(20 points) Assume $n$ is a power of $6$. Assume we are given an algorithm $f(n)$ as follows:
\begin{Verbatim}
function f(n):
if n>1:
for i in range(34):
f(n/6)
for i in range(n*n):
print("Banana")
f(n/6)
else:
print("Monkey")
\end{Verbatim}
\begin{enumerate}[label=(\alph*.)]
\item What is the running time for this function $f(n)$? Justify your answer. (Hint: Recurrences)
\begin{solution}
[Write your answer here]\vspace{12pt}% delete this line and replace with your answer/work
\end{solution}
\item How many times will this function print ``Monkey"? Please provide the exact number in terms of the input $n$. Justify your answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions