[Solved] Generate all permutations of digits in an number of unknown length without using recursion


Recursion is the act of a function calling itself. Under the hood function calls are pushed to the stack of the system and when a function finishes execution, it will be popped from the stack. A stack is a data structure which stores items and has the following operations:

  • push: puts an item to the end of a stack
  • pop: removes an item from the end of a stack and returns it
  • top: returns the item at the end of a stack

You need to define what your stack will store. In our case that could be the current, possibly unfinished permutation. If you want an iterative solution, your job is to handle the stack yourself.

2

solved Generate all permutations of digits in an number of unknown length without using recursion