What's the complexity of the above? It's part of a larger problem where the (1/2) comes from the probability of that happenening, so the worst case is:
T(n) = T(n/2) + c
but the average case is:
T(n) = (1/2)T(n/2) + (1/2)c
Our professor told us that the answer to the worst case is O(n), and that the average case is O(n) as well. This doesn't sit right with me because if you have 10,000 coin flips, you're saying you're expecting 10,000 heads (recurse on heads, break on tails). I said it was O(1) on our midterm, anyone else have any insight?