Permutation algorithms

Made some minor fixes in ```next_permutation```. Also added the remaining permutation algorithms.