The given diagram shows the flowchart for a recursive function . Assume that all statements, except for the recursive calls, have time complexity. If the worst case time complexity of this function is , then the least possible value (accurate up to two decimal positions) of is ________.
Flow chart for Recursive Function .

View worked solution
Answer: 2.32 : 2.33
In the worst-case scenario, the recursive function follows the path in the flowchart that maximizes the number of recursive calls.
From the flowchart, when is odd, the function branches to make recursive calls of size approximately (specifically, and ). When is even, it makes fewer recursive calls. Therefore, the worst-case recurrence relation is:
Applying the Master Theorem for recurrences of the form :
Since , the time complexity is:
Comparing this with , the least possible value of is .
Free practice · Your answers on this page are not saved.
