In Optimal page replacement a page which will be farthest accessed in future will be replaced first.

Here, we have $3$ page frames. Since, initially they are empty the first $3$ distinct page references will cause page faults.

After $3$ distinct page accesses we have $:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&3\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&1&3\\\hline\end{array}}.$

Based on the Next Use Order, the next replacement will be $3.$ Proceeding like this we get

$\overset{\text{Request}}{\boxed{4}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&1&4\\\hline\end{array}} - \text{Miss}.$

$\overset{\text{Request}}{\boxed{2}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&1&4\\\hline\end{array}} - \text{Hit}.$

$\overset{\text{Request}}{\boxed{1}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&4&1\\\hline\end{array}} - \text{Hit}.$

$\overset{\text{Request}}{\boxed{5}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline5&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&4&5\\\hline\end{array}} - \text{Miss}.$

$\overset{\text{Request}}{\boxed{3}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline3&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&4&3\\\hline\end{array}} - \text{Miss}.$

$\overset{\text{Request}}{\boxed{2}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline3&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline4&3&2\\\hline\end{array}} - \text{Hit}.$

$\overset{\text{Request}}{\boxed{4}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&4\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline4&3&2\\\hline\end{array}} - \text{Hit}.$

$\overset{\text{Request}}{\boxed{6}}:\overset{\text{Page Frames}}{\begin{array}{|c|c|c|}\hline1&2&6\\\hline\end{array}}\qquad \overset{\text{Next Use Order}}{\begin{array}{|c|c|c|}\hline2&1&6\\\hline\end{array}} - \text{Miss}.$

(When multiple pages are not going to be accessed again in future, replacing **any **of them is allowed in Optimal page replacement algorithm)

Now, counting the misses which includes the $3$ initial ones we get number of page faults as $3+4 = 7.$

Correct Answer: $7.$