Question: write the C + + code for this program please. the optimal path is the one which has the shortest travel time. You will be

write the C++ code for this program please. the optimal path is the one which has the shortest travel time. You will be implementing the following four search algorithms: Breadth-First Search (BFS), Depth-First Search (DFS), Uniform Cost Search (UCS), and A* Search. Your program will read an input.txt file. The input.txt file will specify one of the four searching algorithms, as well as starting and goal locations. In addition, the input.txt file will contain live traffic information, which is a list of current traveling times (in minutes) between different locations. For example, suppose the starting location is your home and the destination is Staples Center. An example of live traffic data is as follows: Home CA73/NewportCoastDr 5 CA73/NewportCoastDr I405/CA7310 I405/CA73 I110/I40525 I110/I405 I10/I11020 I10/I110 I110/I40530 I10/I110 I10/I4059 I105/I110 I10/I1107 I10/I110 StaplesCenter 3 Here, each line indicates the current traveling time between two locations. For example, line 3 indicates that it takes 25 minutes to go from I405/CA73 to I110/I405. Note that the location can be an intersection (such as I405/CA73). Traveling time may not be the same for both directions. For example, I110/I405 I10/I11020 indicates that it takes 20 minutes to travel from I110/I405 to I10/I110, but I10/I110 I110/I40530 indicates that it takes 30 minutes in the other direction. Beside the live traffic information, you also have an idea of how long it takes on a traffic-free Sunday from each location to your goal location. Hence, the input.txt file will also contain the Sunday traffic estimate of traveling time from each location listed in the file to your destination. For the example above, the Sunday traffic data may look like this: Home 55 CA73/NewportCoastDr 50 I405/CA7340 I110/I40528 I10/I1108 I10/I40539 I105/I11023 StaplesCenter 0 Your program should write, in an output.txt file, the list of locations traveled over in your solution path (including the starting and goal locations) and the accumulated time from start to each location, in order of travel. The following is an example of output.txt: Home 0 CA73/NewportCoastDr 5 I405/CA7315 I110/I40540 I10/I11060 StaplesCenter 63 The full specification of input.txt and output.txt is shown on the next page. Full specification for input.txt: <... LIVE TRAFFIC LINES ...><... SUNDAY TRAFFIC LINES ...> where: is the algorithm to use and will be one of the following: BFS,DFS,UCS,A* is a string with the name of the start location (e.g.,Home) is a string with the name of the goal location (e.g.,StaplesCenter) is the number of lines of live traffic information that follow. <... LIVE TRAFFIC LINES ...> are lines of live traffic information in the format previously described, i.e., is the number of lines of Sunday traffic estimates that follow. <... SUNDAY TRAFFIC LINES ...> are lines of Sunday traffic information in the format previously described, i.e., Full specification for output.txt: Any number of lines with the following format for each line: ****Important guidelines on next two pages**** Guidelines: Your program should not require any command-line argument. It should read a text file called input.txt in the current directory that contains a problem definition. It should write a file called output.txt(in the current directory) with your solution. Format for input.txt and output.txt is specified in the previous page. Samples of input and output are shown on the last few pages of this assignment description. The goal of the samples is to check that you can correctly parse the problem definitions, and generate a correctly formatted output. Your output should match the specified format exactly. It should not be assumed that if your program works on the samples it will work on all test cases.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!