
Computer Science Application
Using Objects Solutions
Get_fastest_route system:
After loading, The Get_fastest_route system determines the shortest
possible route for each truck. In the beginning, its sets the hub address
as a current address, the system uses a greedy approach to compare the
distance from the current address to all other remaining addresses of
packages to find the next stop for the truck. The current address
changes as the truck move each time to find the next closest stop again.
In the end, the system calculates the sum of the total distance traveled
by each truck
Current_address = initialize the current address hub address
Total_distance_tr1=0 while there are packets on truck's list to
deliver: delivery order = sort remaining packages by distance from
current address to delivery address next_closest_stop = obtain the
next closest stop from the delivery_order distance = distance from
Current location to next_closest stop Total_distance_tr1 =
Total distance + distance When the last packet on the truck 1's
assignment list delivered return Total_distance_tr1 .... return
Total distance = Total_distance_tr1+ Total_distance_tr2 +
Total_distance_tr3
I
....
=