Algorithms for Generating Permutations and Combinations