Complete the code to calculate the next disk request chosen by SSTF.
next_request = min(requests, key=lambda r: abs(r - [1]))
The SSTF algorithm selects the request closest to the current head position. Here, current_head_position is used to find the minimum distance.
Complete the code to remove the served request from the list after SSTF selects it.
requests.remove([1])After serving a request, SSTF removes the next_request from the list to avoid serving it again.
Fix the error in updating the current head position after serving a request.
current_head_position = [1]The current head position should be updated to the next_request that was just served, not the minimum or maximum of remaining requests.
Fill both blanks to create a dictionary comprehension that maps each request to its distance from the current head position.
distances = {r: abs(r [1] current_head_position) for r in requests if r [2] current_head_position}The distance is calculated by subtracting the current head position from each request (r - current_head_position). The filter keeps requests greater than the current head position.
Fill all three blanks to create a dictionary comprehension that maps each request to its distance from the current head position, considering requests both less and greater than the head.
distances = {r: abs(r [1] current_head_position) for r in requests if r [2] current_head_position or r [3] current_head_position}The distance is calculated by subtracting the current head position from each request (r - current_head_position). The filter includes requests both greater than and less than the current head position.