Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to complete a Brute Force Algorithm in VB

lydjen81lydjen81 Member Posts: 4
I need to complete a Brute Force Algorithm to find the shortest distance to complete a route with 16 cities (meaning going to all 16 cities which is the shortest route?). I've got the the data showing the distance between each city to each other city. However, I'm not sure how to complete a brute force algorithm. Any suggestions? Anyone know how to complete these in VB....Please help.

Comments

  • zibadianzibadian Member Posts: 6,349
    : I need to complete a Brute Force Algorithm to find the shortest
    : distance to complete a route with 16 cities (meaning going to all 16
    : cities which is the shortest route?). I've got the the data showing
    : the distance between each city to each other city. However, I'm not
    : sure how to complete a brute force algorithm. Any suggestions?
    : Anyone know how to complete these in VB....Please help.
    :
    The easiest is to use a recursive algorithm. Here's the a setup in pseudocode:
    [code]
    GetDistance(FromCity, Distance)
    begin
    if FromCity = DestinationCity then
    begin
    Distance is route length of the starting city to the destination city
    end else for each Connection of FromCity do
    begin
    GetDistance(ConnectionCity, ConnectionDistance+Distance)
    // ConnectionCity = city connected by this connection from fromCity
    // ConnectionDistance = distance from the fromCity to ConnectionCity
    end
    end
    [/code]
Sign In or Register to comment.