GATE / CS ARCHIVE

GATE CSE 1992 / QUESTION 7(b)

Closed form of multiplicative recurrence

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 1992 paper

GATE 1992, Q7(b) Descriptive
Report issue

Asymptotic Analysis & Recurrences

Question 7(b), GATE 1992: The printed function initializes F1←1, tests n=1 and assigns F←3 in that case; otherwise it repeats i=1..n, setting C←0, incrementing C once for each j=1..F(n−1), then setting F1←F1*C. A final F←F1 appears after the loop, with ambiguous if/else grouping. n is positive. Solve the recurrence for a closed form.
Question 7(b), GATE 1992: The printed function initializes F1←1, tests n=1 and assigns F←3 in that case; otherwise it repeats i=1..n, setting C←0, incrementing C once for each j=1..F(n−1), then setting F1←F1*C. A final F←F1 appears after the loop, with ambiguous if/else grouping. n is positive. Solve the recurrence for a closed form.
Tap to enlarge
Answer & solution

Answer: Under intended base F(1)=3, F(n)=3^(n!). Under unconditional final-assignment reading, F(n)=1. (no official key was published)

Using the base-case-preserving reading, F(1)=3 and F(n)=[F(n−1)]n for n≥2. All values are positive, so define an=log₃F(n). Exponentiation becomes multiplication: a1=1 and an=n an−1. Repeated substitution gives an=n(n−1)…2·1=n!, hence F(n)=3n!.

An induction verifies the expression without logarithms. At n=1, 31!=3 equals the base value. If F(n−1)=3^((n−1)!), then F(n)=(3^((n−1)!))n=3^(n·(n−1)!)=3n!. This completes the proof for every positive integer n. Checks at n=2 and n=3 give 9 and 729; n=4 yields 324=282429536481. Confusing 3n! with (3n)! or with 3n would lose the repeated multiplication of exponents.

This formula describes the function’s value under unbounded-integer arithmetic, not the execution time or the size of a machine integer. The return value grows much faster than an ordinary exponential, and practical fixed-width implementations overflow quickly.

The source ambiguity remains material here. If the final F=F1 executes even after n=1 assigns F=3, the true base is 1. Induction on the same recurrence then gives F(n)=1 for all positive n. Thus 3n! is an explicitly conditional intended solution; 1 is the literal unconditional-assignment solution. No verified official key resolves that control-flow formatting.

Original paper, page 6