108 108 votes Consider a computer system with ten physical page frames. The system is provided with an access sequence $(a_{1}, a_{2},....,a_{20}, a_{1}, a_{2},...a_{20})$, where each $a_{i}$ is a distinct virtual page number. The difference in the number of page faults between the last-in-first-out page replacement policy and the optimal page replacement policy is_________. Operating System gatecse-2016-set1 operating-system page-replacement normal numerical-answers + – Sandeep Singh 33.3k views answer comment Share Follow Print See all 20 Comments 20 20 Comments reply Show 17 previous comments Mayank_Pant commented Jul 25 reply Follow flag if in place of LIFO it is LRU then the difference is 10, just a mental exercise. 0 0 replyShare ADIL_DYER commented Aug 7 reply Follow flag can visualise like this : 0 0 replyShare karmakarsupratik10 commented 1 day ago i reshown by karmakarsupratik10 1 day ago reply Follow flag In this question, I have tried a method myself, like here 20 unique elements are having 10 frames, so i scaled down and used a 20/5= 4 unique elements with 10/5=2 frames, hence I have considered the sequence like {1,2,3,4,1,2,3,4} and got LIFO=7 and Optimal fage faults=6 and hence difference as 1. So is it a correct analogy to solve this type of question? 0 0 replyShare Please log in or register to add a comment.
Best answer 100 100 votes Answer is $1$. In LIFO first $20$ are page faults followed by next $9$ hits then next $11$ page faults. (After $a_{10}$, $a_{11}$ replaces $a_{10}, a_{12} $ replaces $a_{11}$ and so on) In optimal first $20$ are page faults followed by next $9$ hits then next $10$ page faults followed by last page hit. Krishna murthy answered Feb 13, 2016 • edited Jun 28, 2018 by kenzou Krishna murthy comment Share Follow See all 7 Comments 7 7 Comments reply Nikhil Jindal commented Feb 15, 2016 reply Follow flag I have a doubt on this one, in LIFO after the first 20 page faults and 9 hits, then the 10th one will replace the 9th page i guess as it is last in first out? 1 1 replyShare Krishna murthy commented Feb 15, 2016 reply Follow flag last in was 20th page. 9th was just a page hit 10 10 replyShare srestha commented Jun 25, 2016 reply Follow flag But in FIFO when a hit occurs , we replace that page last. So, why here we will not think which hit last replaces first? 1 1 replyShare Arjun commented Jun 25, 2016 reply Follow flag @srestha sorry. did not get your question. 1 1 replyShare srestha commented Jun 25, 2016 reply Follow flag Sir I have answered it at last. R u getting it? 0 0 replyShare Harshit Dubey commented Sep 23, 2023 reply Follow flag It can also be solved taking a smaller example like 1,2,3,4,1,2,3,4. Here we can consider the number of physical page frame as 2. 2 2 replyShare Pratham555 commented Jan 18 reply Follow flag Amazing 0 0 replyShare Please log in or register to add a comment.
110 110 votes the answer is $31-30=1$ Rahul Bidla answered Oct 27, 2018 • edited Jan 7, 2019 by Lakshman Bhaiya Rahul Bidla comment Share Follow See all 8 Comments 8 8 Comments reply Show 5 previous comments vivekgatecs2020 commented Dec 2, 2024 reply Follow flag Yes will replace a11 with a2, a12 with a3 and so on according to FIFO Order 1 1 replyShare surya_siddina commented Dec 11, 2024 reply Follow flag Thankyou 0 0 replyShare P_R_A_S_H_A_N_T commented Dec 27, 2025 reply Follow flag nice explanation 👏 0 0 replyShare Please log in or register to add a comment.
9 9 votes In LIFO last access page will be replaces first In LIFO we replace Last access page First . As here First put a1 , then a2.......then a10 . As here 10 frames. Now replaces a10 with a11 to a20. Now we are getting a1 to a9 hit as those are already in first 9 frames. Next a10 will be replace a9 as it is last access frame. And others will replace a10 , a11 will replace a10...........So, a20 will be hit . Same with optimal too srestha answered Jun 25, 2016 srestha comment Share Follow See all 9 Comments 9 9 Comments reply Show 6 previous comments Abhisek Tiwari 4 commented Dec 24, 2018 reply Follow flag @srestha mam plz edit the LIFO definition and ans it may create wrong concept who will not see comment. 3 3 replyShare satyaAchar commented Jul 19, 2024 reply Follow flag @Arjun sir @srestha ma'amwhat about MRU does it follow Last Access or Last In.? 0 0 replyShare sweetjimmy commented Mar 24, 2025 reply Follow flag when a10 comes the second time, it'll replace a20 not a9 0 0 replyShare Please log in or register to add a comment.
5 5 votes YES as you see the que and start solving it you will get the illusion that answer is 0 but if solve question fully...answer will come 1. Rishabh Sharma answered Feb 15, 2016 Rishabh Sharma comment Share Follow See 1 comment 1 1 comment reply Kuljeet Shan commented Apr 18, 2019 reply Follow flag Absolutely right. In optimal one fault is less and that is becoz of a20. a20 is hit in a optimal which is miss is LIFO. 0 0 replyShare Please log in or register to add a comment.
4 4 votes Correct Answer : 1. LIFO Page Faults ==> 20 + 11 = 31 OPTIMAL Algo Page Faults ==> 20+10 = 30 Difference between {LIFO , OPTIMAL} Page Faults = 31-30 = 1. Second Approach: Difference Between Total Hits. Hits in LIFO = 1. Hits in OPTIMAL Algo = 1+1 = 2. Difference between {LIFO , OPTIMAL} Page Faults = 2-1 = 1. Jason GATE answered Jan 7, 2017 Jason GATE comment Share Follow 0 reply Please log in or register to add a comment.
3 3 votes It can also be solved taking a smaller example like 1,2,3,4,1,2,3,4. Here we can consider the number of physical page frame as 2. Thus in LIFO, it comes out to be 7 page fault and in Optimal it is 6. Hence difference is 7- 6 = 1. Harshit Dubey answered Sep 23, 2023 Harshit Dubey comment Share Follow 0 reply Please log in or register to add a comment.