C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Implementation of Recursive Depth First Search Posted by Xee2012 on 22 Sept 2012 at 5:44 PM
I need to solve Travelling Salesman problem using Recursive Depth First Search.I started with reading the text file in 2D array for distances and 1 D array for the cities.Now I need follow the following pseudo code.What I am really confused with is what form of data structure is accepted by the DFS()below.Do I need to get a tree notation first like some link list.

void Depth_first_search(tour_t tour)
{
city_t city;

if (City_count(tour) == n)
{
if (Best_tour(tour))
Update_best_tour(tour);
}
else
{
for each neighboring city
if (Feasible(tour, city))
{
Add_city(tour, city);
Depth_first_search(tour);
Remove_last_city(tour);
}
}
}
Desperately need some relevant help.Thank You



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.