Example of a factorial time algorithm O( n! )
Solution 1:
Generate all the permutations of a list
You have n!
lists, so you cannot achieve better efficiency than O(n!)
.
Solution 2:
Traveling Salesman has a naive solution that's O(n!), but it has a dynamic programming solution that's O(n^2 * 2^n)