来源:微软笔试题。
6、How many times is f() called when calculating f(10)?(5 Points)
int f(int x)
{
if(x <= 2)
return 1;
return f(x - 2) + f(x - 4) + 1;
}
A、14
B、18
C、20
D、24
E、None of the above.
f() 有两个子递归,所以肯定是二叉树状:

数一数节点,有15个节点,所以答案为15。