I've written a brute force search algorithm for the travelling salesman problem, and tested it to see the time it takes for various numbers of 'cities'. From the graph below, we can see that the time is roughly proportional to (n-1)!
where n
is the number of 'cities'. It is not directly proportional to n!
(after all, (n-1)! = n! / n
).
My question is, is it still correct to say that the algorithm runs in O(n!)
, or is it better for me to say O((n-1)!)
? I've never seen the latter before, but it seems more accurate. It seems that I've misunderstood something here.
[t = time taken, n = number of cities]