GATE / CS ARCHIVE

GATE CSE 2016 SET 2 / QUESTION 39

GATE CSE 2016 Set 2 Q39

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 2016 Set 2 paper

GATE 2016 Set 2, Q39 2 marks · NAT
Report issue

Asymptotic Analysis & Recurrences

Question 39, GATE 2016: A recursive flowchart starts with A(n/2), then branches. Left: call A(n/2), return. Right: call A(n/2) twice, then branch to return or call A(n/2) and branch again to return or one final A(n/2) then return. All other work is O(1); assume a constant-size base case and attainable recursive worst branches. Find the least α for worst-case O(n^α), to two decimals.
Tap to enlarge
Answer & solution

Official answer: 2.2 : 2.4

Our answer: log₂5 ≈2.32

Assuming the displayed worst branch can recur and a constant-size base case, T(n)=5T(n/2)+O(1), yielding Theta(nlog₂5). The least exponent islog₂5≈2.32; the official accepted interval 2.2 : 2.4 is preserved.

Only calls on a single executed control-flow path are added. The two alternative exits must not both be counted. At recursion level j, the worst-case tree has 5j calls of size n/2j; after log₂n levels it has 5log₂n=nlog₂5 leaves. This yields the exponent without mistaking five sequential calls for five levels of recursion.

Original paper, page 36 · Answer key