C-SCAN (Circular SCAN)


CSCAN is a modified version of SCAN and deals with its inefficiency in servicing the requests. It moves the head from one end to other end servicing all the requests. As soon as the head reaches the other end, it returns to the beginning without servicing any requests and starts servicing again from the beginning to the other end.


Advantages:


Disadvantages:

Example:

Steps to Implement Algorithm:

  1. Let Request array represents an array storing indexes of tracks or queries that have been requested in ascending order of their time of arrival. 'head' is the position of disk head.
  2. The head services only in the right direction from 0 to the size of the disk.
  3. While moving in the left direction do not service any of the tracks.
  4. When we reach the beginning(left end) reverse the direction.
  5. While moving in the right direction it services all tracks one by one.
  6. While moving in the right direction calculate the absolute distance of the track from the head.
  7. Increment the total seek count with this distance.
  8. Currently serviced track position now becomes the new head position.
  9. Go to step 6 until we reach the right end of the disk.
  10. If we reach the right end of the disk reverse the direction and go to step 3 until all tracks in the request array have not been serviced.

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

Simulate