Question: Task 2: Manage two full lanes with the help with an empty spot, the bubble. The possible moves of a bubble are illustrated below.

Task 2: Manage two full lanes with the help with an empty spot, the bubble. The possible moves of a bubble def swap_to_front (parking_lane, service_lane, car): Description: This function returns a list of move codes 

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

Step by Step Solution

3.32 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

BUBBLE SORT Bubble Sort is a simple sorting algorithm that repeatedly steps through the list compare... 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!