Task 2: Manage two full lanes with the help with an empty spot, the bubble. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 2: Manage two full lanes with the help with an empty spot, the bubble. The possible moves of a bubble are illustrated below. Code O ("shift bubble to the Other lane"): Parking Service Service RTY-5655 ZTR-0976 Parking RTY-5655 ZTR-0976 O FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 FF 22 LKJ-7250 N00B-DRV BSD-9843 ONT123 Code L ("shift bubble to the next Lower index): Parking Service RTY-5655 ZTR-0976 L FF 22 4 LKJ-7250 N00B-DRV BSD-9843 ONT123 Parking Service RTY-5655 FF 22 LKJ-7250 N00B-DRV BSD-9843 ONT123 ZTR-0976 LKJ-7250 NOOB-DRV BSD-9843 ERF-0076 Code H ("shift bubble to the next Higher index); Parking Service RTY-5655 ZTR-0976 H FF 22 ▸ Parking Service RTY-5655 ZTR-0976 FF 22 NOOB-DRV LKJ-7250 BSD-9843 ERF-0076 def swap to_front (parking_lane, service_lane, car): Description: This function returns a list of move codes for the bubble to swap places with other cars so that eventually the specified car shifts to the front of its lane. Parameters: parking_lane (list of strings of the license plates or empty slot in the parking lane) service_lane (list of strings of the license plates or empty slot in the service lane) car (str representing the license plate of the car that needs to be brought to the front) Assumptions: car is an element in one of the parking lane or service_lane lists parking lane and service_lane have equal lengths parking lane and service_lane together do not contain any duplicate strings parking lane and service_lane together contain the empty string in exactly one item Return value: A list [str] representing the codes of bubble moves that bring car to occupy the slot at index 0 in the lane list that contains car. Examples: The sequence of moves ['O', 'H'] brings the highlighted car to the front of its lane: Parking Service FF 22 Parking Service LKJ-7250 FF 22 LKJ-7250 N00B-DRV NOOB-DRV BSD-9843 ONT123 BSD-9843 ERF-0076 The sequence of moves ['L', 'O'. 'H'] brings the highlighted car to the front of its lane: Parking Service FF 22 NOOB-DRV LKJ-7250 BSD-9843 ONT123 0 LKJ-7250 BSD-9843 ONT123 Parking Service FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 Parking Service LFF 22 H Parking Service FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 H Parking Service LKJ-7250 FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 The sequence of moves [] (an empty sequence) brings (leaves) the highlighted car at the front of its lane: Parking Service FF 22 NOOB-DRV NOOB-DRV BSD-9843 ERF-0076 Task 2: Manage two full lanes with the help with an empty spot, the bubble. The possible moves of a bubble are illustrated below. Code O ("shift bubble to the Other lane"): Parking Service Service RTY-5655 ZTR-0976 Parking RTY-5655 ZTR-0976 O FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 FF 22 LKJ-7250 N00B-DRV BSD-9843 ONT123 Code L ("shift bubble to the next Lower index): Parking Service RTY-5655 ZTR-0976 L FF 22 4 LKJ-7250 N00B-DRV BSD-9843 ONT123 Parking Service RTY-5655 FF 22 LKJ-7250 N00B-DRV BSD-9843 ONT123 ZTR-0976 LKJ-7250 NOOB-DRV BSD-9843 ERF-0076 Code H ("shift bubble to the next Higher index); Parking Service RTY-5655 ZTR-0976 H FF 22 ▸ Parking Service RTY-5655 ZTR-0976 FF 22 NOOB-DRV LKJ-7250 BSD-9843 ERF-0076 def swap to_front (parking_lane, service_lane, car): Description: This function returns a list of move codes for the bubble to swap places with other cars so that eventually the specified car shifts to the front of its lane. Parameters: parking_lane (list of strings of the license plates or empty slot in the parking lane) service_lane (list of strings of the license plates or empty slot in the service lane) car (str representing the license plate of the car that needs to be brought to the front) Assumptions: car is an element in one of the parking lane or service_lane lists parking lane and service_lane have equal lengths parking lane and service_lane together do not contain any duplicate strings parking lane and service_lane together contain the empty string in exactly one item Return value: A list [str] representing the codes of bubble moves that bring car to occupy the slot at index 0 in the lane list that contains car. Examples: The sequence of moves ['O', 'H'] brings the highlighted car to the front of its lane: Parking Service FF 22 Parking Service LKJ-7250 FF 22 LKJ-7250 N00B-DRV NOOB-DRV BSD-9843 ONT123 BSD-9843 ERF-0076 The sequence of moves ['L', 'O'. 'H'] brings the highlighted car to the front of its lane: Parking Service FF 22 NOOB-DRV LKJ-7250 BSD-9843 ONT123 0 LKJ-7250 BSD-9843 ONT123 Parking Service FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 Parking Service LFF 22 H Parking Service FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 H Parking Service LKJ-7250 FF 22 LKJ-7250 N00B-DRV BSD-9843 ERF-0076 The sequence of moves [] (an empty sequence) brings (leaves) the highlighted car at the front of its lane: Parking Service FF 22 NOOB-DRV NOOB-DRV BSD-9843 ERF-0076
Expert Answer:
Answer rating: 100% (QA)
BUBBLE SORT Bubble Sort is a simple sorting algorithm that repeatedly steps through the list compare... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Aslam Enterprises is looking to evaluate two investment proposals. The following table indicates the expected cash inflows associated with these particular investment proposals. Both dw vestments...
-
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...
-
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...
-
How do digital media change how we relate to others?
-
This problem6 illustrates how a digital voltmeter affects the voltage across a capacitor in an RC circuit. A digital voltmeter of internal resistance r is used to measure the voltage across a...
-
Solve each system using matrix notation. Express the solution using vectors. (a) 3x + 6y = 18 x + 2y = 6 (b) x + y = 1 x - y = -1 (c) x1 + x3 = 4 x1 - x2 + 2x3 = 5 4x1 - x2 + 5x3 = 17 (d) 2a + b - c...
-
Determined to reduce the \(\$ 7\) per week cost associated with heat loss through their patio window by convection and radiation, the tenants of Problem 9.15 cover the inside of the window with a...
-
Ballard Company rents a warehouse on a month-to-month basis for the storage of its excess inventory. The company periodically must rent space whenever its production greatly exceeds actual sales. For...
-
Mexican Peso Finanicial Statements Assests: Non Curent Assets $ 35,000,000.00 Current Assests $ 5,000,000.00 Total Assests $ 40,000,000.00 Equity $ 25,000,000.00 Non Current Liabilities $...
-
Department Bonus If the Dept is 6007, enter 900, if it is 4305, enter 600, if it is 4312, enter 350, otherwise enter 200. Copy the function down for the employees. Calculate the total Department...
-
You are a university student and eat at your university cafeteria at lunchtime. However, you think it needs some improvements. Write a letter to the university administration explaining what is good...
-
Analyse how McDonald's has navigated the dynamic nature of culture in its global marketing strategies. Specifically, discuss how the company's adaptation to local cultural nuances influences consumer...
-
Calculate the work W done by a force F(x,y)=xi+yj acting on a particle that travels counterclockwise along the cardoid C defined by r(0)=1+sin0, 002x. (Note that [sinxcosxdx = ;sinx +C.)
-
I want know how to use Top-down Approach, Down-up Approach and Market Penetration Rate approach for Estimation of Market Size of the Home Espresso Machines Market in Australia. And use Demographic...
-
When electromagnetic radiation strikes perpendicular to a flat surface, a totally absorbing surface feels radiation pressure Io/c, where Io is the intensity of incident electromagnetic radiation. A...
-
Retail price data for n = 60 hard disk drives were recently reported in a computer magazine. Three variables were recorded for each hard disk drive as shown to the right.. y = Retail PRICE (measured...
-
Find an upper bound for the remainder error if the 2nd Maclaurin polynomial for f(x)= e is used to approximate e? Note: You may assume that e < 2 (this should be clear since e
-
Parkin Industries, a U.S. company, acquired a wholly-owned subsidiary, located in Italy, at the beginning of the current year, for 200,000. The subsidiary's functional currency is the euro. The...
-
Phil and Linda are 25-year-old newlyweds and file a joint tax return. Linda is covered by a retirement plan at work, but Phil is not. a. Assuming Phil's wages were $27,000 and Linda's wages were...
-
In 2012, Margaret and John Murphy are married taxpayers who file a joint tax return with AGl of $25,000. During the year they incurred the following expenses: Hospitalization insurance...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-6. On December 12, Irene purchased the building where her store is located. She paid...
-
Michael has his own consulting firm and works from home. He has the following expenses: Advertising, supplies, car expenses, computer, mortgage interest expense, real estate taxes, and utilities....
-
How would your answers change to Application Problem 8 if the transaction qualified as an excluded transaction? Problem 8 Chase would like to exchange land that he owns (adjusted basis \($140,000\)...
-
Jakari Smith is a new client and has been an investment advice provider as well as an income tax preparer for a well- established firm in the city. He would like to start his own firm as an S...
Study smarter with the SolutionInn App