We give efficient algorithms to sample uniformly, and count approximately, the solutions to a zero-one knapsack problem. The algorithm is based on using dynamic programming to provide a deterministic relative approximation. Then "dart throwing" techniques are used to give arbitrary approximation ratios. We also indicate how further improvements can be obtained using randomized rounding. We extend the approach to several related problems: the mconstraint zero-one knapsack, the general integer knapsack (including its m-constraint version) and contingency tables with constantly many rows. Categories and Subject Descriptors F.2 [Theory of Computation]: Analysis of Algorithms; G.3 [Mathematics of Computing]: Probability. General Terms Algorithms, Theory.
Martin E. Dyer