The GATE Grind

GATE 2016 CS (CS2) – Question 49

Algorithms · Asymptotic Analysis and Time/Space Complexity · 2 marks · Numerical answer

The flowchart defines recursive function A(n). Other statements cost O(1). If worst-case time is $O(n^\alpha)$, find the least α to two decimal places.

Diagram for GATE 2016 CS (CS2) question 49

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 2.2 to 2.4

Explanation

The longest execution path calls A(n/2) six times: twice initially, twice along the middle branch, once below, and once on the final left branch. Hence $T(n)=6T(n/2)+O(1)$. The master theorem gives $\alpha=\log_2 6=2.58496$, rounded 2.58.

More Asymptotic Analysis and Time/Space Complexity questions

All Asymptotic Analysis and Time/Space Complexity questions →