## neal young / Khare13First

• Can one choose a good Huffman code without knowing the underlying distribution? The following Online Slot Allocation (OSA) problem models this and similar problems. Given $$n$$ nonnegative slot costs $$c(1), c(2), ..., c(n)$$, requests for items are drawn from a hidden probability distribution $$p$$ on $$[n]$$, and revealed online one by one. In response to each request, if the item has not been previously requested, the algorithm (knowing only $$c$$ and the items requested so far) must allocate some unused slot for the item. The objective is to minimize the cost of the slot allocation, which is the sum, over the items, of the probability of the item times the cost of its assigned slot.

The online First-Come-First-Served algorithm (FCFS) simply allocates the cheapest slot available when an item needing a slot arrives. FCFS is optimal among online algorithms. For general costs, we show that its competitive ratio is $$1+\ln n$$. For concave costs, its competitive ratio is 2. For logarithmic costs, the ratio is, asymptotically, 1: the algorithm's expected cost is $$\mbox{opt} + O(\log \mbox{opt})$$.

A practical application of OSA is Online Huffman Coding (OHC), a variant of Huffman coding in which the codewords must be allocated on demand, without knowing the underlying probability distribution. OHC reduces to OSA, yielding a first-come-first-served algorithm for OHC that guarantees near-optimal expected cost, at most $$\mbox{opt} + 2 \log(1+\mbox{opt}) + 2$$.