SCAN (Elevator) and C-Scan SCAN: Service the first request encountered in the current head direction C-Scan: Services in one direction; SCAN: Services in both directions C-Scan: Return to the beginning after each pass (circular list) Head going left Movement = 236 cylinders Head going right Movement = 382 cylinders • C-Scan: Provides a more uniform wait time than SCAN. • Repositioning to the beginning is faster than repositioning in small pieces because of acceleration and deceleration.
From Idea to Solution for (int i = 0; i < list.length; i++) { select the smallest element in list[i..listSize-1]; swap the smallest with list[i], if necessary; // list[i] is in its correct position. // The next iteration apply on list[i..listSize-1] } list[0] list[1] list[2] list[3] ... list[10] list[0] list[1] list[2] list[3] ... list[10] list[0] list[1] list[2] list[3] ... list[10] list[0] list[1] list[2] list[3] ... list[10] list[0] list[1] list[2] list[3] ... list[10] ... list[0] list[1] list[2] list[3] ... list[10]