Discuss situations under which the least frequently used page-replacement algorithm generates fewer page faults than the least recently used pagereplacement algorithm. Also discuss under what circumstance does the opposite holds.
Consider the following sequence of memory accesses in a system that can hold four pages in memory. Sequence: 1 1 2 3 4 5 1. When page 5 is accessed, the least frequently used page-replacement algorithm would replace a page other than 1, and therefore would not incur a page fault when page 1 is accessed again. On the other hand, for the sequence "1 2 3 4 5 2," the least recently used algorithm performs better.