Using Lambda expressions, write a function List getRandomSubset( List list) that returns a random subset of arbitrary size. All subsets (including the empty set) should be equally likely to be chosen.

We can generate a random subset by iterating through the list and flipping a coin (i.e., deciding on a 50/50 chance) to pick whether or not each element will be in it.

results matching ""

    No results matching ""