New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Travelling Salesman problem using C++ Programming


Posted Date:     Total Responses: 0    Posted By: Gowri M   Member Level: Bronze   Points/Cash: 4   


## This project is for Travelling Salesman problem using dynamic programming for 1st year MCA students in C++ Programming

#include
#include
#include
#define max 100
#define infinity 999
int tspdp(int c[][max],int tour[],int star,int n);
int main()
{
int n;
int i,j,c[max][max];
int tour[max],cost;
cout<<"Travelling Salesman Problem Using Dynamic Programming\n";
cout<<"\nEnter number of cities to traverse";
cin>>n;
cout<<"Enter cost matrix\n"<
for(i=0;ifor(j=0;j{

cin>>c[i][j];
if(c[i][j]==0)
c[i][j]=999;
}

for(i=0;itour[i]=i;
cost=tspdp(c,tour,0,n);
cout<<"Minimum Cost:"<cout<<"Tour:\n";
for(i=0;icout<cout<<"1\n";
getch();
return 0;
}

int tspdp(int c[][max],int tour[],int start,int n)
{
int i,j,temp[max],mintour[max];
int mincost,ccost;

if(start==n-2)
return c[tour[n-2]][tour[n-1]]+c[tour[n-1]][0];
mincost=infinity;
for(i=start+1;i{
for(j=0;jtemp[j]=tour[j];
temp[start+1]=tour[i];
temp[i]=tour[start+1];
if(c[tour[start]][tour[i]]+(ccost=tspdp(c,temp,start+1,n)){
mincost=c[tour[start]][tour[i]]+cost;
for(k=0;kmintour[k]=temp[k];
}
}
for(i=o;itour[i]=mintour[i];
return mincost;
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: Bacteria Diversity
Previous Project: EFFECTIVENESS OF RECRUITMENT & SELECTION PRACTICES

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.