Optimal selection and sorting via dynamic programming
Micha Hofri · ACM Journal of Experimental Algorithmics · 2013
We show how to find optimal algorithms for the selection of one or more order statistics over a small set of numbers, and as an extreme case, complete sorting. The criterion is using the smallest number of comparisons; separate derivations are performed for minimization on the average (over all permutations) or in the worst case. When the computational process establishes the optimal values, it also generates C-language functions that implement policies which achieve those optimal values. The search for the algorithms is driven by a Markov decision process, and the program provides the optimality proof as well.