In the diagram above, process P4, which has the shortest burst time of 3 ms, started running on the CPU first. Afterwards, process P1 with the next shortest burst time of 6 ms ran, and so on. The average waiting time in this schedule is (0 + 3 + 9 + 16)/4 = 7 milliseconds, which is the same as the average response time. Note that if FCFS were used, the average waiting time would be 10.25 ms.
As we mentioned before, it is possible to prove mathematically that SJF yields the shortest possible average waiting time.
Note that those processes with the longer burst times will run the last, after the smaller processes finished running.