0
  1. SHOW_SCHEDULE(START_CITY, START_STATE , HOURS)

This function looks at the current set of campaign stops that is stored in the system to create a schedule for the candidate. The schedule includes a subset of the current set of stored campaign stops and the route information between these campaign stops. The schedule must include the maximum number of campaign stops that can be accommodated within a given number of hours. START_CITY, START_STATE together denote the first city in the schedule. HOURS denote the number of hours for which the schedule is being made.

What will be the best algorithm for this function??

luser droog
  • 18,988
  • 3
  • 53
  • 105

1 Answers1

0

You could look at this answer which talks about Djikstra's Algorithm for routing (you would probably need to define your graph such).

Basically, have your stops as vertices and the route could be treading these vertices.

Now, since you bring in the time dimension, his makes the route somewhat non-static static. Have a look at Distance Vector routing, again as suggested in the above mentioned answer.

The below links should give some more insights and comparision on routing algorithms

  1. Wikipedia Journey Planner
  2. This paper compares other algorithms that are faster than Djikstra's algorithm
Community
  • 1
  • 1
Srikanth Venugopalan
  • 9,011
  • 3
  • 36
  • 76