Heap's algorithm for permutation of characters in a string