ProAlgos/ProAlgos-Cpp

Add Heap's algorithm for string permutations

a-moreira opened this issue · 4 comments

I'd like to add the Heap's Algorithm to generate all permutations of a string. I've already implemented it according to the guidelines. Just need to polish some things up.

Great! Let us know if you have any questions.

@alxmjo Actually I have one. The Heap's Algorithm trusts the input has no duplicate elements since it does not distinguish between repeated permutations. I could deal with this by making it return a std::set with the permutations, but that would add an additional log n complexity. How should I proceed?

I think that since the algorithm is predicated on the understanding that each element is unique it's okay to assume that and forgo the set implementation. This brings up a whole other conversation about verifying algorithm input, but as I said, I think that's a separate conversation.

Go ahead and implement it the way you had planned and then we can address issues as they come up.

@alxmjo All right. I just added the pull request.