in reply to Pick k numbers at random

A fairly-stupid but actually very-effective recursive algorithm that I once encountered basically consisted of the following:
function populate(lo,hi, depth) { if (lo >= hi) return; if (depth > MAX_DEPTH) return; midpoint = rand(lo,hi); add_to_result(midpoint); populate(lo, midpoint-1, depth+1); populate(midpoint+1, hi, depth+1); }

Replies are listed 'Best First'.
Re^2: Pick k numbers at random
by Anonymous Monk on Nov 15, 2019 at 18:00 UTC

    You didn't understand the OP's concerns, you regurgitated a CS 102 solution that you "encountered", and you posted pseudocode instead of Perl.

    Is anyone surprised? I'm not.