# optimal path for traversing nodes

So here is the problem: There are n objects in a super market that you need to retrieve, then you need to go to the cashier register in the end. How do you find the best path of traversing the least distance to retrieve the objects and finally go to the cashier register?

I could only find a brute force method of finding optimal path of each permutation of paths and seeing which overall distance covers the least traversing. But this implementation is O(n!). Is there a more efficient approach?

• en.wikipedia.org/wiki/Travelling_salesman_problem – François Aug 14 '15 at 7:40
• @François so there is not way to solve it better than exponential time? – Armon Safai Aug 14 '15 at 8:57
• It depends on the possible super market topologies. If it's still a corridor and if objects positions are integers, then you can solve your problem in linear time. – François Aug 14 '15 at 15:21
• @François well its no A corridor. I'm assuming multiple corridors (or isles). – Armon Safai Aug 14 '15 at 20:43
• If an approach solution is ok for you, you can look at cs.brown.edu/~pnk/publications/tsp2005.pdf – François Aug 15 '15 at 8:04