Disk Scheduling (LOOK)
Disk Scheduling (LOOK)
Simulate the LOOK disk scheduling algorithm.
Types
type DiskResult struct {
Order []int
Seek int
}
func ScheduleLOOK(head int, dir int, requests []int) DiskResult
Rules
headis the current head position.diris the initial direction:1for increasing tracks,-1for decreasing.- LOOK services all requests in the current direction (sorted), then reverses.
- The head does not go to the end of the disk, only as far as the last request.
Output
Order: the sequence of serviced requests.Seek: total head movement (sum of absolute deltas).
Notes
- If
requestsis empty, return empty order and zero seek.
Run tests to see results
No issues detected