Week - 4, Graded Programming Problem 3 Long journey A tourist wants to travel around India...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
You can use the following Python function to find the route for the tourist python def ongJourneyA... View the full answer
Related Book For
Intermediate Accounting Volume 1
ISBN: 9781260306743
7th Edition
Authors: Thomas H. Beechy, Joan E. Conrod, Elizabeth Farrell, Ingrid McLeod Dick
Posted Date:
Students also viewed these programming questions
-
Explain three sources of short-term finance used by a company and why these sources are important. Define Working Capital & its importance.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Mansfield Congregational Church (MCC) is a small organization in Connecticut with only seventeen employees. Though its funds are dwindling, the MCC wants to hire a full-time maintenance employee to...
-
Suppose that trees are distributed in a forest according to a two-dimensional Poisson process with parameter a, the expected number of trees per acre, equal to 80. a. What is the probability that in...
-
Joseph Mitsch purchased a used Chevrolet Yukon SUV vehicle from Rockenbach Chevrolet. The Yukon was manufactured by General Motors Corporation (GMC). The Yukon had been driven over 36,000 miles. The...
-
Focusing on Cash Flows: Matching Cash Flow Items to Categories LO1-1 Cheez. Inc. produces, markets, and distributes a wide variety of products to customers in many countries. Its products include...
-
Aerkion Company starts 2015 with two assets: cash of 20,000 LCU (local currency units) and land that originally cost 70,000 LCU when acquired on April 4, 2005. On May 1, 2015, Aerkion rendered...
-
2. For each situation, draw a vector diagram and calculate the resultant force: a) F1 = 150 N (west) and F2 = 420 N (East). Include a diagram. [2] b) F1 = 180 N at a bearing of 040 and F2 = 270 N at...
-
Given the time-phased work packages and network, complete the baseline budget form for theproject. Market Survey Project WBS Work Package Cost by Week WP Design 4 5 2 WP Survey 2244 4 5 WP Report 3 3...
-
Determine whether the set equipped with the given operations is a vector space. For those that are not vector spaces identify the vector space axioms that fail. The set of all n-tuples of real...
-
What are the key molecular mechanisms that govern cell polarity, and how does the disruption of these mechanisms affect tissue architecture and organ function ?
-
5. dx Find when y x-2x+1 = x+2x-1'
-
Explain the impact of chromosomal rearrangements and translocations on gene expression, and how these genetic abnormalities can lead to leukemias and other types of cancer
-
13-21 Suppose someone borrows from a bank to buy a new car. A few months later, the borrower realizes that he will have to default on this loan in a few months, after which the bank will repossess...
-
9. Evaluate the following limits x-2x (i) limx-2 x2-5x+6. sin4x (ii) limx-o sin2x
-
ACT PREP MATH PART-ACT Math Test 1-Edition Question 9 of 60 What are the solns for 01+ and - and-7-yi 0-7+ - and -T-M 0 4+ and 4- Ned Reset (3x+5)(3x-5)=(2 + 2)(x+5)
-
From a medical tourist perspective, compare Shouldice with the traditional hospital in terms of the key factors of competition. Using Table 15-3, why would Shouldice attract patients from outside the...
-
On 1 July 20X2, New Company purchased $600,000 of Old Corp. 5.5% bonds, classified as an AC investment. The bonds pay semi annual interest each 30 June and 31 December. The market interest rate was...
-
Identify whether the following items in comprehensive income will be reclassified to net income or not reclassified. Reclassifled Not Reclassifled 1. FVOCI financial asset 2. Foreign currency...
-
A. Voluntary accounting policy change B. Involuntary accounting policy change C. Change in accounting estimate D. Correction of an error E. None of the above _____ 1. This is the first year the...
-
Which biases may have entered into the boards decision making? Pat and Chris were hired by Central O. District Hospital (CODH) as part of a three-year management contract with HCA Management Company....
-
How can healthcare decisions be improved?
-
How is Grahams situation a possible example of confirmingevidence bias? Graham ruled with an iron will. He felt that the only way to motivate his employees was by giving them clear direction and...
Study smarter with the SolutionInn App