Question: (4 marks) Consider the following recursive algorithm Fct(n) which can take any integer n0 as input. begin{tabular}{l} hline Algorithm 1Fct(n) hline 1: if n3


(4 marks) Consider the following recursive algorithm Fct(n) which can take any integer n0 as input. \begin{tabular}{l} \hline Algorithm 1Fct(n) \\ \hline 1: if n3 then \\ 2: return 1 \\ 3: else \\ 4: return Fct(n2)+2Fct(n3)+2n \\ 5: end if \end{tabular} Let W(n) be the number of multiplications () done in a call to Fct(n). Which of the following expressions describes W(n) ? Let W(n) be the number of multiplications () done in a call to Fct(n). Which of the following expressions describes W(n) ? W(n)=1 for n3, and W(n)=W(n2)+2W(n3) for n>3 All other answers are wrong. W(n)=0 for n3, and W(n)=W(n2)+W(n3)+2 for n>3 W(n)=0 for n3, and W(n)=W(n2)+W(n3) for n>3 W(n)=1 for n3, and W(n)=W(n2)+2W(n3)+2n for n>3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
