几道算法题
1.There is a prize hidden in a box; the value of the prize is a positive integer between 1 and N, and you aregiven N. To win the prize, you have to guess its value. Your goal is to do it in as few guesses as possible. You
start with a number of chips (specified below). Each chip allows you one guess that’s too high. If you guess
too high, and you have no chips, you lose. So, for example, if you start with no chips, then you can win in N
guesses by simply guessing the sequence 1, 2, 3, ... .
Suppose you start with 1 chip. Describe a strategy that makes O(pN) guesses.
2. Use the Carter-Wegman trick to determine the value of 1463528785364712 mod 99999999 without using any
calculating devices or long division. You have a limit of ten lines for your answer.
3. Suppose you have N rational numbers r1, r2, r3, ...rN, whose numerators and denominators are all between
1 and N; you may assume all the rational numbers have value at least 1. Show how to sort these numbers
in linear time, assuming that any operations on the numerators or denominators (adds, subtracts, multiplies,
integer divides, and integer mod operations) take constant time. Hint: Linear-time sorts are generally done by
radix sort. Suppose ri − rj > 0. What is the minimum value of ri − rj?
求大神指点,看不大懂,还有这几题的解题思路是怎样的。