SCAN (Elevator Algorithm)


Scan is often called Elevator Scheduling Algorithm, due to the way it works.
In SCAN, disk arm starts from one end of the disk and executes all the requests in its way till it reaches the other end.
As soon as it reaches the other end, it reverses its direction, hence it moves back and forth continuously (like an elevator) to access the disk.


Advantages:


Disadvantages:

Example:

Steps to Implement Algorithm:

  1. Let Request array represents an array storing indexes of tracks that have been requested in ascending order of their time of arrival. 'head' is the position of disk head.
  2. Let direction represents whether the head is moving towards left or right.
  3. In the direction in which head is moving service all tracks one by one.
  4. Calculate the absolute distance of the track from the head.
  5. Increment the total seek count with this distance.
  6. Currently serviced track position now becomes the new head position.
  7. Go to step 3 until we reach at one of the ends of the disk.
  8. If we reach at the end of the disk reverse the direction and go to step 2 until all tracks in request array have not been serviced.

Time Complexity: O ( N * logN )   Auxiliary Space: O ( N )

Simulate