Complete the code to select the initial direction for the SCAN algorithm.
direction = [1] # Choose initial head movement direction
The SCAN algorithm moves the disk head initially towards the right (higher track numbers) or left (lower track numbers). Commonly, it starts moving right.
Complete the code to find the next request to service in the LOOK algorithm.
next_request = min([r for r in requests if r > current_head], default=[1])
In LOOK, if no requests are ahead, min returns None to indicate no next request in that direction.
Fix the error in the code that updates the head position after servicing a request in SCAN.
current_head = [1] # Update head to the serviced request
The head should move to the position of the serviced request, which is stored in next_request.
Fill both blanks to complete the condition that reverses direction in SCAN when no requests remain in current direction.
if not any(r [1] current_head for r in requests): direction = [2]
If no requests are greater than the current head, the direction reverses to left.
Fill all three blanks to complete the LOOK algorithm's main loop for servicing requests.
while requests: if direction == [1]: next_request = min([r for r in requests if r > current_head], default=None) else: next_request = max([r for r in requests if r < current_head], default=None) if next_request is None: direction = [2] if direction == [1] else [1] continue current_head = [3] requests.remove(next_request)
The LOOK algorithm moves right or left depending on direction, reverses when no requests remain in that direction, and updates the head to the next request.
