SJF
// SJF code #include <stdio.h> #include <limits.h> #define NUM_PROCESSES 5 void sortProcesses (int at [ ], int bt [ ], int p[ ], int n) { for (int i = 0; i < n - 1; i++) { for (int j =0; j < n - i - 1; j++) { if ( at[ j ] > at[ j + 1] ) { int temp = at[ j ]; at[ j ] = at[j + 1]; at[ j+1]= temp; temp = bt[ j ]; bt[ j ] = bt[ j + 1]; bt[ j+1 ]= temp; temp = p[j]; p[j] = p[j + 1]; p[j+1]= temp; } } } } int main() { int p[NUM_PROCESSES] = {1, 2, 3, 4, 5}; int at[NUM_PROCESSES] = {2, 1, 4, 0, 2}; int bt[NUM_PROCESSES] = {1, 5, 1, 6, 3}; int ct[NUM_PROCESSES] = {0}; int tat[NUM_PROCESSES] = {0}; int wt[NUM_PROCESSES] = {0}; int rt[NUM_PROCESSES] = {0}; int isCompleted[NUM_PROCESSES]={0}; int time = 0, completed = 0; float avg_tate = 0, avg_wt = 0, avg_rt = 0; sortProcesses(at, bt, p, NUM_PROCESSES); while (completed < NUM_PROCESSES) { int idx = -1; int min_bt = INT_MAX; for (...