Optimal Page Replacement Algorithm in C

Here you will get program for optimal page replacement algorithm in C.

Optimal page replacement algorithm says that if page fault occurs then that page should be removed that will not be used for maximum time in future.

It is also known as clairvoyant replacement algorithm or Bélády’s optimal page replacement policy.

Also Read: LRU Page Replacement Algorithm in C

Video Tutorial

Below program shows how to implement this algorithm in C.

Program for Optimal Page Replacement Algorithm in C

Output

Enter number of frames: 3
Enter number of pages: 10
Enter page reference string: 2 3 4 2 1 3 7 5 4 3

2 -1 -1
2 3 -1
2 3 4
2 3 4
1 3 4
1 3 4
7 3 4
5 3 4
5 3 4
5 3 4

Comment below if you have doubts or found anything incorrect in above optimal page replacement algorithm in C.

Leave a Reply

Your email address will not be published. Required fields are marked *