Complete the solution to the HPAir problem The input to the

Complete the solution to the HPAir problem. The input to the program consists of three text fi les, as follows: cityFile Each line contains the name of a city that HPAir serves. The names are in alphabetical order. flightFile Each line contains a pair of city names that represent the origin and destination of one of HPAir’s fl ights. requestFile Each line contains a pair of city names that represent a request to fl y from some origin to some destination. Programming Problems 223 You can make the following assumptions: • Each city name contains at most 15 characters. Pairs of city names are separated by a comma. • HPAir serves at most 20 cities. • The input data is correct. For example, the input fi les could appear as cityFile: Albuquerque Chicago San Diego flightFile: Chicago, San Diego Chicago, Albuquerque Albuquerque, Chicago requestFile: Albuquerque, San Diego Albuquerque, Paris San Diego, Chicago For this input, the program should produce the following output: Request is to fly from Albuquerque to San Diego. HPAir flies from Albuquerque to San Diego. Request is to fly from Albuquerque to Paris. Sorry. HPAir does not serve Paris. Request is to fly from San Diego to Chicago. Sorry. HPAir does not fly from San Diego to Chicago. Begin by implementing the ADT fl ight map as the C++ class Map. Use the stack version of isPath . Because getNextCity is the primary operation that the search algorithm performs on the fl ight map, you should choose an implementation that will effi ciently determine which cities are adjacent to a given city. If there are n cities numbered 1, 2, . . ., n, you can use n chains of linked nodes to represent the fl ight map. You place a node on list i for city j if and only if there is a directed path from city i to city j . Such a data structure is called an adjacency list; Figure 6-14 illustrates an adjacency list for the fl ight map in Figure 6-6 . Chapter 20 discusses adjacency lists further when it presents ways to represent graphs. At that time, you will learn why an adjacency list is a good choice for the present program.

Solution

In graph theory and computer science, an adjacency list is a collection of unordered lists used to represent a finite graph. Each list describes the set of neighbors of a vertex in the graph.

Example for the adjacency list -:

0 -> 1 6 8

1 -> 0 4 6 9

2 -> 4 6

3 -> 4 5 8

4 -> 1 2 3 5 9

5 -> 3 4

6 -> 0 1 2

7 -> 8 9

8 -> 0 3 7

----------------------------------------------------------------------------------------------------------------------

#include <iostream>
#include <fstream>
#include<string.h>
using namespace std;

int main ()
{
streampos begin,end;
ifstream file1,file2,file3;
file1.open (\"cityFile.txt\"); //cityFile open
file2.open(\"flightFile.txt\");
file3.open(\"requestFile.txt\");
  
// ifstream myfile (\"example.bin\", ios::binary);
int i=0,j=0,k=0;
while(!file1.eof())
{
word += static_cast<char>(x); //get the word by word \'word\' Array.
word += file1.split[\" \"](i); // this and above statements are true you can used any of this
i= i+1;
   x= file1.get();   
}
while(!file2.eof())
{
word1 += static_cast<char>(x); //get the word by word \'word1\' Array.
word1 += file2.split[\",\"](i); // In here when the comma seen then it splits to two words
i= i+1;
   x= file2.get();   
}
while(!file3.eof())
{
word2 += static_cast<char>(x); //get the word by word \'word2\' Array.
word2 += file3.split[\",\"](i); // this and above statements are true you can used any of this
k = k+1;
   x= file3.get();   
}
for(int i=0;i<word1.length;i++){
   for(int j=0;j<word1.length;j++){
  
cout << \" Request is to fly from\" << word1[i] << \"to\" << word2[j] <<\"\ \";
cout << \" HPAir flies from\" << word1[i] << \"to\" << word2[j] <<\"\ \";
cout << \"Request is to fly from \" << word1[i] << \"to\" << word2[j] <<\"\ \";
}
}
return 0;
}

Complete the solution to the HPAir problem. The input to the program consists of three text fi les, as follows: cityFile Each line contains the name of a city t
Complete the solution to the HPAir problem. The input to the program consists of three text fi les, as follows: cityFile Each line contains the name of a city t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site