Background
I am trying to work through some problems I found from Stanfords "Design & Analysis of Algorithms" course from 2013. In particular, problem 3 from problem set 1 here.
In summary it states:
- You are stuck on a desert island with a radio that can transmit a distress signal at integer power levels (i.e. 1W, 2W, 3W, etc.).
- If you transmit a signal with high enough power, you will receive a response and be rescued.
- Unfortunately you do not know how much power, n, is needed.
The problem requests you design an algorithm that uses Θ(n)W total power.
Being a 5pt question from problem set 1, I presume this is easier than I am finding it.
My question is
...what is this algorithm?....or how can I change my thinking to find one?
Where I'm stuck
The question states that the strategy "just increase power by 1 watt each time" will result in an Θ(n^2)W total power. Indeed, this is true, as the total power used by any n is n * (n+1) / 2.
However, I can't think of any strategy that isn't:
- greater than linear; or
- a strategy where I cheat by "not doing anything for a few consecutive n's".
Also, if I ignore the discreteness of the radio for a minute and analyse the problem as a continuous linear function, the total power should be generalisable to a function g(n) of the form g(n) = Kn + B (where K and B are constants). This linear function would represent the integral of the function we need to use for controlling the radio.
Then, if I take the derivative of this function, dg(n)/dn, I'm left with K. I.e. If I want to have linear total power, I should just drive the radio at a constant power for n times...but this would only result in a rescue if I happened to guess K correctly the first time.
EDIT
Yes, I had already thought of doubling etc....but the answers here pointed out the error in my thinking. I had been trying to solve the question "design an algorithm that has linear cumulative power consumption"...which I think is impossible. As pointed out by the answers, I should have thought about it as "for a given n, design an algorithm that will consume Kn"...i.e. what the question posed.