Asymptotic Analysis & Recurrences


Answer & solution
Answer: Intended base-case-preserving reading: F(1)=3, F(n)=F(n−1)^n for n>1. Literal unconditional final assignment instead gives F(n)=1 for all n. (no official key was published)
First distinguish the function’s returned numerical value from its running time. In one outer iteration the inner loop increments C exactly F(n−1) times, so C=F(n−1). Starting from F1=1, the outer loop multiplies by that same value n times. Hence for n>1 the returned value is F(n)=∏[i=1..n] F(n−1)=[F(n−1)]n. The base is F(1)=3 if the base-case assignment is returned without being overwritten.
A block-explicit rendition of this intended reading is:
function F(n):
if n=1 then return 3;
F1:=1;
for i:=1 to n do begin
C:=0;
for j:=1 to F(n−1) do C:=C+1;
F1:=F1*C
end;
return F1.This explains why neither n·F(n−1) (a sum) nor a runtime recurrence answers the value question. For instance F(2)=3²=9 and F(3)=9³=729.
The paper places a final F=F1 after the if/else loop without clearly enclosing it in the else branch. Under a literal Pascal-like reading with that assignment executed unconditionally, n=1 first sets F=3 but then overwrites it with the initial F1=1. The recurrence becomes F(1)=1, F(n)=F(n−1)n and all values are 1. The intended nontrivial recurrence therefore requires treating the final assignment as part of the else computation or returning immediately from the n=1 case.