shortest job remaining first please note arrival time and burst please use spaces to separate times entered calculate the waiting time of each processes return list of waiting times calculatewaitingtime1 2 3 4 3 3 5 1 4 0 3 5 0 calculatewaitingtime1 2 3 2 5 1 3 0 2 0 calculatewaitingtime2 3 5 1 2 1 0 copy the burst time into remainingtime process until all processes are completed find finish time of current process calculate waiting time increment time calculate the turn around time of each processes return list of turn around times calculateturnaroundtime3 3 5 1 4 0 3 5 0 3 6 10 1 calculateturnaroundtime3 3 2 0 3 3 6 calculateturnaroundtime8 10 1 3 1 0 3 9 10 4 this function calculates the average of the waiting turnaround times prints average waiting time average turn around time calculateaveragetimes0 3 5 0 3 6 10 1 4 average waiting time 2 00000 average turn around time 5 0 calculateaveragetimes2 3 3 6 2 average waiting time 2 50000 average turn around time 4 5 calculateaveragetimes10 4 3 2 7 6 3 average waiting time 5 66667 average turn around time 5 0 printing the dataframe calculate the waiting time of each processes return list of waiting times calculate_waitingtime 1 2 3 4 3 3 5 1 4 0 3 5 0 calculate_waitingtime 1 2 3 2 5 1 3 0 2 0 calculate_waitingtime 2 3 5 1 2 1 0 copy the burst time into remaining_time process until all processes are completed find finish time of current process calculate waiting time increment time calculate the turn around time of each processes return list of turn around times calculate_turnaroundtime 3 3 5 1 4 0 3 5 0 3 6 10 1 calculate_turnaroundtime 3 3 2 0 3 3 6 calculate_turnaroundtime 8 10 1 3 1 0 3 9 10 4 this function calculates the average of the waiting turnaround times prints average waiting time average turn around time calculate_average_times 0 3 5 0 3 6 10 1 4 average waiting time 2 00000 average turn around time 5 0 calculate_average_times 2 3 3 6 2 average waiting time 2 50000 average turn around time 4 5 calculate_average_times 10 4 3 2 7 6 3 average waiting time 5 66667 average turn around time 5 0 printing the dataframe
from __future__ import annotations

import pandas as pd


def calculate_waitingtime(
    arrival_time: list[int], burst_time: list[int], no_of_processes: int
) -> list[int]:
    
    remaining_time = [0] * no_of_processes
    waiting_time = [0] * no_of_processes
    
    for i in range(no_of_processes):
        remaining_time[i] = burst_time[i]

    complete = 0
    increment_time = 0
    minm = 999999999
    short = 0
    check = False

    
    while complete != no_of_processes:
        for j in range(no_of_processes):
            if arrival_time[j] <= increment_time and remaining_time[j] > 0:
                if remaining_time[j] < minm:
                    minm = remaining_time[j]
                    short = j
                    check = True

        if not check:
            increment_time += 1
            continue
        remaining_time[short] -= 1

        minm = remaining_time[short]
        if minm == 0:
            minm = 999999999

        if remaining_time[short] == 0:
            complete += 1
            check = False

            
            finish_time = increment_time + 1

            
            finar = finish_time - arrival_time[short]
            waiting_time[short] = finar - burst_time[short]

            if waiting_time[short] < 0:
                waiting_time[short] = 0

        
        increment_time += 1
    return waiting_time


def calculate_turnaroundtime(
    burst_time: list[int], no_of_processes: int, waiting_time: list[int]
) -> list[int]:
    
    turn_around_time = [0] * no_of_processes
    for i in range(no_of_processes):
        turn_around_time[i] = burst_time[i] + waiting_time[i]
    return turn_around_time


def calculate_average_times(
    waiting_time: list[int], turn_around_time: list[int], no_of_processes: int
) -> None:
    
    total_waiting_time = 0
    total_turn_around_time = 0
    for i in range(no_of_processes):
        total_waiting_time = total_waiting_time + waiting_time[i]
        total_turn_around_time = total_turn_around_time + turn_around_time[i]
    print(f"Average waiting time = {total_waiting_time / no_of_processes:.5f}")
    print("Average turn around time =", total_turn_around_time / no_of_processes)


if __name__ == "__main__":
    print("Enter how many process you want to analyze")
    no_of_processes = int(input())
    burst_time = [0] * no_of_processes
    arrival_time = [0] * no_of_processes
    processes = list(range(1, no_of_processes + 1))

    for i in range(no_of_processes):
        print("Enter the arrival time and burst time for process:--" + str(i + 1))
        arrival_time[i], burst_time[i] = map(int, input().split())

    waiting_time = calculate_waitingtime(arrival_time, burst_time, no_of_processes)

    bt = burst_time
    n = no_of_processes
    wt = waiting_time
    turn_around_time = calculate_turnaroundtime(bt, n, wt)

    calculate_average_times(waiting_time, turn_around_time, no_of_processes)

    fcfs = pd.DataFrame(
        list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)),
        columns=[
            "Process",
            "BurstTime",
            "ArrivalTime",
            "WaitingTime",
            "TurnAroundTime",
        ],
    )

    
    pd.set_option("display.max_rows", fcfs.shape[0] + 1)
    print(fcfs)