correct implementations of SELECT and RANDOMIZED-SELECT