I'm having trouble creating a recursive algorithm to find the number of n word permutations given a linked list of strings.
So, the function should take the linked list of strings and output a linked list of all possible concatenated permutations of those strings, separated by spaces.
Essentially, if the linked list was say ("cat", "dog", "mouse"), and n was 3, it should return: "cat dog mouse", "cat mouse dog", "dog cat mouse", "dog mouse cat", "mouse cat dog", and "mouse dog cat".
Similarly, if n was 2, it should return: "cat dog", "cat mouse", "dog cat", "dog mouse", "mouse cat", and "mouse dog".
I can't seem to figure out a solution.
Recursion involves finding an inductive case and a base case. The inductive case takes you one step closer to the solution, while the base case solves a small version of the problem.
In this case, your base case is "find all permutations of a list with one element." There is only one value in this set, the string itself.
A great candidate for your inductive case would be "for each string in the set, return the concatenation of that string with each of the permutations of the set without that string".