For the second but last level (which will be entered n! times) it is doing n iterations which gives us a (not so tight) lower bound of n * n! instead of the optimal n!.
The issue is the use of an array for visited instead of, say, a linked list where each level gets a list of only unvisited nodes.
For the second but last level (which will be entered n! times) it is doing n iterations which gives us a (not so tight) lower bound of n * n! instead of the optimal n!.
The issue is the use of an array for visited instead of, say, a linked list where each level gets a list of only unvisited nodes.