MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / calculate_turnaround_times

Function calculate_turnaround_times

scheduling/first_come_first_served.py:26–44  ·  view source on GitHub ↗

This function calculates the turnaround time of some processes. Return: The time difference between the completion time and the arrival time. Practically waiting_time + duration_time >>> calculate_turnaround_times([5, 10, 15], [0, 5, 15]) [5, 15,

(
    duration_times: list[int], waiting_times: list[int]
)

Source from the content-addressed store, hash-verified

24
25
26def calculate_turnaround_times(
27 duration_times: list[int], waiting_times: list[int]
28) -> list[int]:
29 """
30 This function calculates the turnaround time of some processes.
31 Return: The time difference between the completion time and the
32 arrival time.
33 Practically waiting_time + duration_time
34 >>> calculate_turnaround_times([5, 10, 15], [0, 5, 15])
35 [5, 15, 30]
36 >>> calculate_turnaround_times([1, 2, 3, 4, 5], [0, 1, 3, 6, 10])
37 [1, 3, 6, 10, 15]
38 >>> calculate_turnaround_times([10, 3], [0, 10])
39 [10, 13]
40 """
41 return [
42 duration_time + waiting_times[i]
43 for i, duration_time in enumerate(duration_times)
44 ]
45
46
47def calculate_average_turnaround_time(turnaround_times: list[int]) -> float:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected