arrow
arrow
arrow
For the reference string: (given that number of frames is 3) 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 For the optimal page replacement algorithm, w
Question

For the reference string: (given that number of frames is 3)
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
For the optimal page replacement algorithm, which of the following will represent the hit ratio?

A.

11/20

B.

10/20

C.

9/20

D.

12/20

Correct option is A

We are given the reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
Number of frames: 3
We need to calculate the hit ratio using the Optimal Page Replacement Algorithm.
The Optimal Page Replacement algorithm replaces the page whose next occurrence is farthest in the future (or which will not be used again).
Let's trace the reference string.

Step
Page
Frames after reference
Hit/Fault
1
7
7
Fault
2
0
7, 0
Fault
3
1
7, 0, 1
Fault
4
2
2, 0, 1
Fault
5
0
2, 0, 1
Hit
6
3
2, 0, 3
Fault
7
0
2, 0, 3
Hit
8
4
2, 4, 3
Fault
9
2
2, 4, 3
Hit
10
3
2, 4, 3
Hit
11
0
2, 0, 3
Fault
12
3
2, 0, 3
Hit
13
2
2, 0, 3
Hit
14
1
2, 0, 1
Fault
15
2
2, 0, 1
Hit
16
0
2, 0, 1
Hit
17
1
2, 0, 1
Hit
18
7
7, 0, 1
Fault
19
0
7, 0, 1
Hit
20
1
7, 0, 1
Hit

Counting the Hits
Hits occur at:
5, 7, 9, 10, 12, 13, 15, 16, 17, 19, 20
Therefore, the total number of hits is: 11
Total number of page references: 20
Thus, the hit ratio is:
Hit Ratio=Number of HitsTotal References=1120\text{Hit Ratio}= \frac{\text{Number of Hits}}{\text{Total References}} =\frac{11}{20}​​
Hit Ratio=11/20\boxed{\text{Hit Ratio}=11/20}​​
Information Booster
1. Optimal Page Replacement replaces the page that will be referenced farthest in the future.
2. It produces the minimum possible number of page faults for a given reference string.
3. Hit ratio is:
Number of HitsTotal References\boxed{\frac{\text{Number of Hits}}{\text{Total References}}}​​
4. Page-fault ratio is:
Number of Page FaultsTotal References\boxed{\frac{\text{Number of Page Faults}}{\text{Total References}}}​​
5. For this problem:
Hits=11,Faults=9\text{Hits}=11,\qquad \text{Faults}=9​​
Additional Knowledge
Since:
Hits+Faults=20\text{Hits}+\text{Faults}=20​​
we have:
11 + 9 = 20
Therefore:
Hit Ratio=1120=0.55=55%\boxed{\text{Hit Ratio}=\frac{11}{20}=0.55=55\%}​​
and the page-fault ratio is:
920=45%\boxed{\frac{9}{20}=45\%}​​

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
527k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow