Shortest Job First (SJF) Scheduling
Intervals and Scheduling DSA practice problem on Onlearn.
Difficulty: medium.
Topics: Implementing Shortest Job First (SJF) Algorithm to Calculate Average Waiting Time, Greedy Algorithm, Sorting, Scheduling Problems, Array Manipulation, Time Complexity, Space Complexity, space complexity, greedy algorithm, sorting algorithms, time calculation, scheduling algorithms, time complexity analysis, Minimum Platforms.
Shortest Job First Scheduling Problem Statement: Given an array jobs where jobs[i] represents the duration of the ith job, implement the Shortest Job First (SJF) scheduling algorithm to calculate the average waiting time for all jobs. The waiting time for a job is defined as the total time all previous jobs took to complete before this job starts execution. Input: An array of integers jobs (1 ≤ |jobs| ≤ 10^5) Each job duration jobs[i] (1 ≤ jobs[i] ≤ 10^9) Output: The average waiting time as a floating point number Examples: Constraints: The input array may contain duplicate values All jobs are available at time 0 No preemption (jobs run to completion once started)