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:
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...
-
Determine the maximum uniform loading w, measured in lb/ft, that the cable can support if it is capable of sustaining a maximum tension Tmax before it will break. Given: Tmax = 3000 lb a = 50 ft b =...
-
How do advanced spectroscopic techniques such as NMR spectroscopy, FTIR spectroscopy, and X-ray diffraction enable the elucidation of molecular-level interactions and structural changes in complex...
-
Prove that $R^{2}$ is the square of the correlation between $\mathbf{y}$ and $\hat{\mathbf{y}}$.
-
The following is a true case. General Electric (GE), like many other large corporations, is scrutinized by financial analysts who develop quarterly forecast EPS figures for the company. The companies...
-
The number of customers arriving at Soda Mart follows a Poisson distribution with a mean of 22 customers per hour. What is the probability 40 customers will arrive in two (2) hours?
-
In alphabetical order below are balance sheet items for Mendoza Company at December 31, 2017. Kathy Mendoza is the owner of Mendoza Company. Prepare a balance sheet, following the format of...
-
Bahrain Company reported the following costs and expenses for the most recent month: Direct materials $80,000 Direct labor $42,000 Manufacturing overhead (3/5 is fixed).. Selling expenses (1/2 is...
-
Develop the appropriate primary research question to be associated with this design. Develop a hypothetical research scenario that would necessitate the use of a Regression-Discontinuity...
-
Research shows that taking photos of experiences with the intention to share them reduces ones enjoyment of the experience. This happens because the goal of sharing involves the possibility of...
-
The chapter emphasizes the importance of design thinking to create products that are Easy and fun for people to use. Find an example of a product you own that is not user friendly. How might you...
-
Adidas provoked outrage when the company posted a photo of a new design, the JS Roundhouse Mids, on its Facebook page. The shoes come with bright orange shackles and the tagline Got a sneaker game so...
-
Develop the appropriate primary research question to be associated with this design. Develop a hypothetical research scenario that would necessitate the use of a Longitudinal Design. The research...
-
Random variable z follows the standard normal distribution. In each of the following, sketch the standard normal distribution to illustrate your result. Use 4 decimal places. (a)[3] Find P(-3.0 z ...
-
Use the graphs of f and g to graph h(x) = (f + g) (x). To print an enlarged copy of the graph, go to MathGraphs.com. 1. 2. y 24 8. 2. -2 -2 4 6
-
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...
-
The accounting records of the Happy Tickers Sports and Social Club are in a mess. You manage to find the following information to help you prepare the accounts for the year to 31 December 2015. (1)...
-
The Milham Theatre Club has been in existence for a number of years. Members pay an annual subscription of 15 which entitles them to join trips to professional productions at a reduced rate. On 1...
-
Place a tick in the appropriate column for each of the following cost items: (a) Purchases of raw materials (b) Direct wages (c) General factory expenses (d) Depreciation of machinery (e) Commission...
Study smarter with the SolutionInn App