Let A be any set and let S A be the set of all permutations of A . Let f , g , h in S A . Write your answer as a composition of one or more disjoint cycles. Obviously, f is a permutation. However, if we try to build a cycle, as we did for permutations of finite sets, the process is never going to stop.
All storage locations are initially empty.
A string such as 10020340 cannot be handled by this procedure, because we cannot pop two integers from a stack containing only one integer. Indeed, if the first integer which is popped out is 4, then there is no 0 in the string before 4. But then, the string is 12340000, and the resulting permutation should be 4321 instead. Exercise 6 Draw all binary trees on 1,2,3 and 4 nodes. Use recursion to prove it.