آخرین مطالب
Output
The cost of most efficient tour = 80

Time Complexity : O(n2*2n) where O(n* 2n) are maximum number of unique subproblems/states and O(n) for transition (through for loop as in code) in every states.

Auxiliary Space: O(n*2n), where n is number of Nodes/Cities here.

For a set of size n, we consider n-2 subsets each of size n-1 such that all subsets don’t have nth in them. Using the above recurrence relation, we can write a dynamic programming-based solution. There are at most O(n*2n) subproblems, and each one takes linear time to solve. The total running time is therefore O(n2*2n). The time complexity is much less than O(n!) but still exponential. The space required is also exponential. So this approach is also infeasible even for a slightly higher number of vertices. We will soon be discussing approximate algorithms for the traveling salesman problem.

Next Article: Traveling Salesman Problem | Set 2 

References: 

http://www.lsi.upc.edu/~mjserna/docencia/algofib/P07/dynprog.pdf 

http://www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf 

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Solve DSA problems on GfG Practice.

Solve Problems

[/membership]

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *