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
- Consider a Binary Search Tree (BST) where every node stores a key and two child pointers. What is the time complexity of finding the Lowest Common Ancestor...
- Which type of attack allows an attacker to inject malicious scripts into a trusted website to execute in a victim's browser?
- Which of the following query will return the third-highest salary from an Employee table in SQL?
- Which of the following operations is most efficient in a singly linked list compared to an array?
- Which phase of the Software Development Lifecycle (SDLC) focuses on identifying the feasibility and goals of the project?
- Which of the following is NOT a best practice for implementing disaster recovery plans?
- In the context of Intelligent Systems, which of the following algorithms is primarily used for real-time pathfinding in robotics?
- Which of the following is a critical component of a data protection policy that supports regulatory compliance?
- What will be the output of the following JavaScript code when executed? let xhr = new XMLHttpRequest(); xhr.open("GET", "https://api.example.com/data", fal...
- In data analytics, which algorithm is commonly used for predictive modeling when the target variable is categorical?
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