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 phase of the Software Development Lifecycle (SDLC) focuses on identifying the feasibility and goals of the project?
- Which of the following is the primary difference between a public cloud and a private cloud?
- Recursion uses
- Dynamic programming is used by
- Which protocol is responsible for resolving IP addresses to MAC addresses in a local network?
- What is a common security control used to protect sensitive data during transmission over the internet?
- Which of the following is a primary reason for using digital signatures in modern cryptography?
- Bitwise operators in C++
- In the design and analysis of algorithms, which of the following algorithms is based on the greedy approach?
- Which of the following best describes the concept of abstraction in object-oriented programming (OOP)?
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)