Reservoir sampling in C