Travelling Salesman Problem is defined as “Given a list of cities and the distances between each pair of cities, what is the
shortest possible route that visits each city exactly once and returns to the origin city?” It is an NP-hard problem.
Bellman–Held–Karp algorithm:
Compute the solutions of all subproblems starting with the smallest. Whenever computing a solution requires solutions for
smaller problems using the above recursive equations, look up these solutions which are already computed. To compute a minimum
distance tour, use the final equation to generate the 1st node, and repeat for the other nodes. For this problem, we cannot
know which subproblems we need to solve, so we solve them all.
Program in C :
Output:
Please comment below in case of any problem found during running the code or any other doubts.
Computer Science Major, Bioinformatics Bachelor, Deep Learning enthusiast, hard core Gamer , occasional Philosopher, avid music listener and movie lover. Visit my other blog for Gaming and Technical review related posts @ Blogger; also feel free to post a question @ Quora (links below)
How to modify Service Fabric replicator log size and also how to change Service Fabric Local cluster installtion directory or log directory. Continue reading