11-01-2018, 01:28 PM

As the problem states: For example, if the invocation of f(a) finds table[a] non-empty and it is the first invocation to do so, then f(a) would be the answer.

Clearly f(2) is the first invocation to find a non-empty slot in the table. f(3) does not until after f(2). f(4) does not until after f(2).

Your logic for this problem is faulty. Here's why:

Clearly f(0) and f(1) involve the base cases. I'm sure we all agree on that.

You seem to be saying that since f(2) calls f(0) and f(1) and f(0) and f(1) involve base cases, then f(2) also involves base cases. By that logic, since f(3) calls f(2) and f(2) involves base cases, then f(3) involves base cases. Likewise, f(4) involves base cases since it calls f(3), and so on.

Under your interpretation, to get this chain to stop at f(2) and f(3), you have to change the wording of the question.

That said, I will accept 4 and 3 as an alternate answers, but those are not a logical results.

Clearly f(2) is the first invocation to find a non-empty slot in the table. f(3) does not until after f(2). f(4) does not until after f(2).

Your logic for this problem is faulty. Here's why:

Clearly f(0) and f(1) involve the base cases. I'm sure we all agree on that.

You seem to be saying that since f(2) calls f(0) and f(1) and f(0) and f(1) involve base cases, then f(2) also involves base cases. By that logic, since f(3) calls f(2) and f(2) involves base cases, then f(3) involves base cases. Likewise, f(4) involves base cases since it calls f(3), and so on.

Under your interpretation, to get this chain to stop at f(2) and f(3), you have to change the wording of the question.

That said, I will accept 4 and 3 as an alternate answers, but those are not a logical results.