The following algorithm does not use recursion. Instead, it uses a manual stack and a loop to permute Strings. (It can easily be modified to permute other data types.) Like the recursive algorthims shown above, the overall length of code is surprisingly short. The algorithm is much easier to understand than its recursive counterparts. The marker character mentioned in the algorithm is any character that is guaranteed not to be in the original data set. It is recommended that you use a "/" character as the marker when implementing this algorithm.
create a stack
append a marker character to the target string and push result into the stack
while the stack is not empty do:
pop the next string off the stack and save it in a temp variable
if temp starts with marker character, remove marker and save it in a set as part of the solution. then continue while loop.
if temp does not start with marker character, do a for loop:
move each character before the marker to the end of the string.
save in a new variable called item. (do not disturb temp)
push item into the stack
print solution set