Hi,
I'm enrolled on a 3rd year BSc Computing Science degree and currently undertaking a module 'Algorithms & Collections'. I have been given the task to map out the activation records for the following piece of code:
int mystery(int n)
{
// Base Case
if (n <= 0) { return 0; }
// Recursive (general) case
return mystery( n / 2 ) + 1;
}
However, what I am confused about, is how the answer is 5?
If anyone could help me understand this it would be greatly appreciated!
Edit: My apologies, I meant, I can't seem to get why the answer would be 5 upon invoking mystery(20)? ![]()
Edited by martintaylor1635, 11 March 2021 - 01:17 PM.



Back to top







