We really shouldn't do your homework for you, but you have at least made an effort.

Suppose you guess a number r, 0 <= r < n.

In case a) you have a 1/n chance of guessing the correct number, but if you are wrong

you have no other information to help you narrow your search, so the number of valid

answers is reduced by just 1. On average, it would take you n/2 + n/2 guesses to

determine x and y. Worst case would be 2n guesses (suppose x and y were both n-1).

In case b) if you guess wrong, you can subset the numbers. Suppose your initial guess

is r = n/2, and it is wrong, say A says x < r. In that case you can eliminate half of the

possible answers - limiting the next guess between 0 and r-1 (do you sense recursion here?).

This is called a binary search (dividing the solution space in half each time). I leave it up

to you to determine the maximum number of comparisons needed to determine both

values in this case.

Suppose you guess a number r, 0 <= r < n.

In case a) you have a 1/n chance of guessing the correct number, but if you are wrong

you have no other information to help you narrow your search, so the number of valid

answers is reduced by just 1. On average, it would take you n/2 + n/2 guesses to

determine x and y. Worst case would be 2n guesses (suppose x and y were both n-1).

In case b) if you guess wrong, you can subset the numbers. Suppose your initial guess

is r = n/2, and it is wrong, say A says x < r. In that case you can eliminate half of the

possible answers - limiting the next guess between 0 and r-1 (do you sense recursion here?).

This is called a binary search (dividing the solution space in half each time). I leave it up

to you to determine the maximum number of comparisons needed to determine both

values in this case.