Questions 1, 2, and 3 are rather interesting and have what I'd judge to be reasonably correct answers. Question 4 is boring and questions 5 - 7 don't really have correct answers at all, which is a little surprising for Yahoo. Who messes up their technical geekery this bad?

Question 1 can be done by first renumbering all weights under w = 55 + x, so that in x-space the equivalent problem is [0, 2, 3, 4, 5, 6, 7, 8, 10, 11].

The benefit of starting with 0 is that you know that the first two numbers are -k and +k, because they have to sum to 0. They aren't both 0, so starting with -1 and +1 gives you the answer pretty simply in a generative way: you say "the next largest number I need to make is 2, that requires 2 - (-1) = 3, the next largest number I need to make is 3, that requires 3 - (-1) = 4, the next largest number I need to generate is 6, which requires 7, check that I'm done, I am, so there you have it, (54, 56, 58, 59, 62).

Question 2 requires calculating the two line extrema which aren't triangles: 12 - 5 = 7, 12 + 5 = 17. Then rule out the middle zone where (5, 12, x) is acute -- this happens between the two right triangles (5, 12, 13) and (5, 10.908..., 12). So we rule out (11, 12, 13) and we're left with (8, 9, 10, 14, 15, 16), which has length 6.

Question 3 required a bit of mental insight. Let f(n, x) mean "the numer of ways to form x with bills denoted 1, 2, ..., n". Then f(1, x) = 1 and f(n, negative) = 0, and f(n, 0) = 1.

Then there is a recursion relation: you can either form x using the largest bill n, or you can form it without; the number of ways to do it the first way is f(n, x - n) and the number of ways to do it the second way is f(n - 1, x). Thus:

f(n, x) = f(n, x - n) + f(n - 1, x)

Which means, following the recursion:

f(n, x) = f(n - 1, x) + f(n - 1, x - n) + ...

For n = 2 it's clear that f(2, x) = ceil((x+1)/2), just following out the pattern. All you need to know is that asymptotically this is x/2. This means that f(3, x) will sum for large x a set of linearly increasing terms. They will average x/4, since they start pretty much at 0 and go pretty much to x/2. There will be x/3 terms. So the sum must asymptotically grow like x^2/12.

So, right, question 5. The first of the stupid questions. As far as I can tell the loop intended is while(0);, and because it loops precisely zero times, every predicate -- even the false predicates -- are true all of the times that it loops. All five options are technically correct. (And even if we restrict them to the ones which happen when the loop decides that it's not going to happen in the first place, there still seem to be multiple true assertions.)

Question 6 is bad first off because it starts with an incomplete and irrelevant sentence; the question has no single answer because it depends on what the exact model is on disk. If you store all the records in a single file on disk, and you only naively count disk IOs, then in principle the lookup without the B+ tree can be done in one long disk IO whereas with the lookup with the B+ tree will probably take more disk IOs as we skip the irrelevant parts to save memory. (This is especially true if the B+ tree is stored on disk alongside those records, since the access pattern would be highly nonlinear.) If they're in different files scattered across the drive then that's a different question, and the unindexed content needs to query all N records, requiring you to request N separate IOs, while the indexed content does not ever need, as far as I'm aware, to backtrack, and therefore can do it in N or fewer IOs.

Question 7 is also horrible because it only has a valid answer under the assumption that peoples' marks are unique, and the most obvious way to make this assumption is to assume that the kids are being marked 1 for top place, 2 for second place, et cetera. If they are being marked with normal grades, some kid gets 100, another kid gets 98, two kids get 97, and so on -- then uniqueness is trashed and none of the answers are valid. First off, it's not the "8th highest mark" in the sense of the "8th highest person with the highest mark" because that person might share a mark with the 7th highest person, and therefore would not fulfill the NOT IN clause. It is not the "8th highest mark" in the sense of the "8th highest mark awarded" because the inner select is not UNIQUE and therefore there is no good way to say how many unique marks there are therein.

After that many screwups on Yahoo's part I just decided that this test annoyed the crap out of me. I try not to program in C when I can help it, which turns out to fortunately be most of the time, so the barrage of questions about what exactly certain C programs do would be educated guesses anyway.