Recursive Permutations

Recursion String Algorithm

Recursive Permutations

On November 9, 1989, a significant moment marked the fall of the Berlin Wall, a historic event symbolizing the dismantling of barriers. Today, you will tackle a different kind of barrier – the challenge of generating all permutations of a given string using recursion.

Problem Statement

Write a recursive function that takes a string as input and returns a list (or array) of all possible permutations of that string. The order of permutations in the output does not matter. Assume that the input string contains unique characters.

Requirements

  • Use recursion to generate the permutations without using library functions that directly provide permutations.
  • Ensure that the function handles the base case when the string is empty or has a single character.

Example

For the input 'abc', possible outputs include:

[ "abc", "acb", "bac", "bca", "cab", "cba" ]

Starter Code

Below is some starter code in multiple languages to help you get started.