Professional Documents
Culture Documents
Experiment 2.4: Aim: Implement Travelling Salesperson Problem Using Dynamic Programming
Experiment 2.4: Aim: Implement Travelling Salesperson Problem Using Dynamic Programming
UID: 20BCG1092
Program Code
#include<iostream>
//Next distan array will give Minimum distance through all the position
int distan[10][10] = {
};
int DP[16][4];
return distan[position][0];
}
if(DP[mark][position]!=-1){
return DP[mark][position];
// answer
//Visit rest of the unvisited cities and mark the . Later find the
for(int city=0;city<n;city++){
if((mark&(1<<city))==0){
int main(){
for(int i=0;i<(1<<n);i++){
for(int j=0;j<n;j++){
DP[i][j] = -1;
return 0;
}
Output
6. LEARNING OUTCOMES: