FOR FREE CONTENT

GATE question on Optimal algorithm

 

Q. GATE 2014-SET 2-Q33 

Assume that there are 3 frames that are initially empty. If the page reference string is 

 

1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6 the number of page fault using the optimal replacement policy is______.

 

Answer is number of page faults: 7

 

You should know: 

Before seeing the solution please follow the previous chapter: 

Optimal Page Replacement algorithm.

 

Solution and explanation:

Given page references: 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6

 

 

Number of page faults is 7.

 

Shortcut method:

But in examination it is not possible to solve it by this elaborative way we can do it by a single frame like below:

 

 

The above process is a shortcut and the easiest process to calculate page faults.

 

So, the number of page faults is 7.

 

To know more about how the page is replacing here by optimal page replacement policy please follow the previous chapter: Optimal Page Replacement algorithm.