0
0
Operating Systemsknowledge~5 mins

LOOK and C-LOOK variants in Operating Systems - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: LOOK and C-LOOK variants
O(n log n)
Understanding Time Complexity

We want to understand how the time to schedule disk requests grows as the number of requests increases in LOOK and C-LOOK algorithms.

How does the number of disk requests affect the total operations needed to service them?

Scenario Under Consideration

Analyze the time complexity of the LOOK disk scheduling algorithm variant.

function LOOK(requests, head) {
  sort requests by track number
  direction = choose initial direction
  while requests remain {
    move head in direction servicing requests until no more in that direction
    reverse direction
  }
}

This code moves the disk head back and forth, servicing requests in order along the track numbers.

Identify Repeating Operations

We look for repeated actions that affect time.

  • Primary operation: Scanning and servicing requests in sorted order along the disk tracks.
  • How many times: Each request is visited once during the head movement in one direction.
How Execution Grows With Input

As the number of requests grows, the head must move to each request once, scanning through them in order.

Input Size (n)Approx. Operations
10About 10 moves to service all requests
100About 100 moves, scanning through requests
1000About 1000 moves, one per request

Pattern observation: The operations grow roughly in direct proportion to the number of requests.

Final Time Complexity

Time Complexity: O(n log n)

This means the time to service all requests grows linearly with the number of requests after sorting.

Common Mistake

[X] Wrong: "LOOK and C-LOOK algorithms take longer than scanning all requests because they move the head back and forth multiple times."

[OK] Correct: Each request is serviced once in order, so the total work grows linearly after sorting. The back-and-forth movement is efficient and does not multiply the work.

Interview Connect

Understanding how disk scheduling algorithms scale helps you explain system efficiency clearly and confidently in interviews.

Self-Check

What if the requests were not sorted first? How would that affect the time complexity?