Question
What will be the output of the following code snippet implementing the Least Recently Used (LR
- U page replacement algorithm? def lru(pages, capacity): page_frame = [] page_faults = 0 for page in pages: if page not in page_frame: if len(page_frame) < capacity: page_frame.append(page) else: lru_page = min(page_frame, key=lambda p: pages.index(p)) page_frame.remove(lru_page) page_frame.append(page) page_faults += 1 return page_faults pages = [7, 0, 1, 2, 0, 3, 0, 4, 2, 3] capacity = 4 faults = lru(pages, capacity) print(faults)
More Basics of Computers Questions
- Which data structure is most suitable for implementing a priority queue?
- In the context of virtualization, paravirtualization differs from full virtualization in which of the following ways?
- Which phase of systems analysis and design focuses on specifying the functional requirements of a system?
- What will be the output of the following code when implementing the SCAN I/O scheduling algorithm? def scan(requests, head, direction): seek_sequence =...
- Which of the following is a characteristic of an intelligent agent?
- In JavaScript, which method is used to parse a string into a JSON object?
- Which of the following protocols is used for remotely managing network devices?
- Which command would you use to change the permissions of a file in a Unix/Linux environment?
- Operator overloading in C++
- Identify correct statement w.r.t Java Syntax
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)