Add algorithm and test for next_permutation

Added algorithm and test for ```next_permutation```