Question: Week - 4, Graded Programming Problem 3 Long journey A tourist wants to travel around India from north to south. He has a policy

Week - 4, Graded Programming Problem 3 Long journey A tourist wants to travel around India from north toSample Adjacency List Open with Google Docs 1 {'Madurai': ['Cochin', 'Kanyakumari'], 2 'vaishali': 0. 3Sample Output I 1 ['Leh', 'Shimla', 'Rishikesh', 'Delhi', 'Sravasti', 'Kushinagar', 'Sarnath', 'Varanasi',Jaipur: [Pushkar'], Mumbai: [Goa'], Ajanta': [Ellora, Aurangabad']} Test Case 2 Input (Agra': [Ranthambore'],

Week - 4, Graded Programming Problem 3 Long journey A tourist wants to travel around India from north to south. He has a policy that he never travels back towards the north. Write a Python function longJourney (AList) to find him a route with which he can visit the maximum number of cities according to his policy, where AList represents a graph of cities and routes between them. Every edge in adjacency list AList is a feasible route between one city to another from north to south. The function should return a list in the order the cities are to be visited to visit maximum cities. An example of cities and route between them(as edge) is shown below. Shumla Rishikesh Agra Gir Delhi Pushka Rantliambre Stavasti Jaipur Udaipor Ellora Khajuraho RUMAH Aurangabad Ajanta Varanasi Bauali Mambal Clou Kolkata Bodhgaya vakumari Thiruvanandhapuram Sample Adjacency List Open with Google Docs 1 {'Madurai': ['Cochin', 'Kanyakumari'], 2 'vaishali': 0. 3 'Varanasi': ['Khajuraho', 'Bodhgaya'], 4 'Thiruvanandhapuram': ['Kanyakumari'], 5 'Udaipur': ['Gir', 'Ajanta'], 6 'Rishikesh': ['Delhi']. 7 'shimla': ['Rishikesh']. 8 'Bangalore': ['Chennai', 'Madurai']. 9 'Agra': ['Ranthambore']. 10 'Ellora': ['Aurangabad'], 11 'Bodhgaya': ['kolkatta']. 12 'Cochin': ['Thiruvanandhapuram'], 13 'Pushkar': ['udaipur', 'Ranthar ore']. 14 'Ranthambore': ['Khajuraho']. 15 'Gir': [], 16 'Aurangabad': ['Mumbai']. 17 'Kolkatta': ['Ajanta', 'Bangalore', 'Chennai']. 18 'Chennai': ['Madurai'], 19 'Sravasti': ['Kushinagar'], 20 'Leh': ['shimla'], 21 'Sarnath': ['Varanasi'], 22 'Delhi': ['Jaipur', 'Agra', 'Sravasti'], 23 'Goa': ['Cochin', 'Bangalore'], 24 'Kanyakumari': [], 25 'Kushinagar': ['Sarnath', 'vaishali'], 26 'Khajuraho': ['Ajanta'], 27 'Jaipur': ['Pushkar'], 28 'Mumbai': ['Goa'], 29 'Ajanta': ['Ellora', 'Aurangabad']} Sample Output I 1 ['Leh', 'Shimla', 'Rishikesh', 'Delhi', 'Sravasti', 'Kushinagar', 'Sarnath', 'Varanasi', 'Bodhgaya', 'Kolkatta', 'Ajanta', 'Ellora', 'Aurangabad", 'Mumbai', 'Goa', 'Bangalore', 'Chennai', 'Madurai', 'Cochin', 'Thiruvanandhapuram', 'Kanyakumari'] Jaipur: [Pushkar'], Mumbai: [Goa'], Ajanta': [Ellora, Aurangabad']} Test Case 2 Input (Agra': [Ranthambore'], 'Delhi: [Jaipur, 'Agra', 'Sravasti], 'Jaipur: [Pushkar], 'Kushinagar': [, Leh': ['Shimla], Pushkar: [Ranthambore], Ranthambore': 0, Rishikesh: ['Delhi'], 'Shimla': [Rishikesh'], Sravasti: [Kushinagar']} Test Case 3 Input (Agra": [Ranthambore], Expected Output [Leh', Shimla, Rishikesh, Delhi, Jaipur, Pushk Expected Output [Leh', 'Shimla', 'Rishikesh, Delhi, Sravasti, Kusl Actual Output Actual Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

You can use the following Python function to find the route for the tourist python def ongJourneyA... View full answer

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!