Question
What will be the output of the following code when implementing the SCAN I/O scheduling algorithm? def scan(requests, head, direction): seek_sequence = [] distance = 0 cur_track = 0 if direction == "left": requests.sort(reverse=True) else: requests.sort() for track in requests: if cur_track < track: seek_sequence.append(cur_track) distance += abs(track - cur_track) cur_track = track return seek_sequence, distance requests = [98, 180, 37, 122, 14, 124, 65, 67] head = 50 direction = "right" seek_sequence, total_distance = scan(requests, head, direction) print(seek_sequence) print(total_distance)
More Basics of Computers Questions
- Which attack type specifically targets application-layer protocols like HTTP, DNS, and SMTP?
- What will be the output of the following code snippet demonstrating abstraction in Python? from abc import ABC, abstractmethod class Shape(ABC): @abst...
- Which is/are Keyword in C++
- The primary role of an operating system (OS) is to:
- The important aspect of data warehouse environment is that data found within the data warehouse is
- The values appearing in given attributes of any tuple in the referencing relation must likewise occur in specified attributes of at least one tuple in the ...
- Which of the following protocols is used for resolving IP addresses to MAC addresses in a network?
- In terms of processor performance, which factor refers to the number of cycles a processor executes per second?
- Which of the following page replacement algorithms results in the lowest page-fault rate for a given reference string but is often impractical to implement...
- Which of the following statements correctly describes a major difference between public and private clouds?
Relevant for Exams:
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)