You arrive at a ski resort. Renting skis costs $1 a day. Buying a pair costs $10, once, and then you ski for free forever. The catch: you have no idea how many days you'll ski. The weather, your knee, your budget — any day could be your last.
If you knew you'd ski 20 days, you'd buy on day one. If you knew you'd ski 3 days, you'd just rent. But you don't know. Every morning you must commit money before the future reveals itself.
This tiny dilemma is the ski-rental problem, and it is the friendliest gateway to online algorithms: making irreversible decisions as data arrives, one piece at a time, with no peek at what comes next. The surprise is that a one-line rule does almost as well as a fortune teller.
Comments
Loading comments...