Question: You need to implement the FIFO algorithm and the FF algorithm ( Furthest - in - Future algorithm ) for the offline caching problem. Please

You need to implement the FIFO algorithm and the FF algorithm (Furthest-in-Future algorithm) for the offline caching problem. Please provide the sum of the FIFO solution and the FF solution in the first line of the output, and the difference between the FIFO solution and the FF solution in the second line of the output. An O(n+mk) time algorithm is sufficient to pass any feasible test cases.
Input: You need to read the input from the console. In the first line of the input, we have three positive integer k, n and m. k is the size of the cache, n is the number of pages, and m is the number of page requests. The pages are indexed from 1 to n. You can assume that 1<= k <=100,1<= n <=1000 and 1<=m<=10000. In the next m lines, each line contains 1 integers: psi_i [n]. This indicates that there is a request psi_i in the sequence request.
Output: You need to output to the console. The output consists of two lines: the sum of the FIFO solution and the FF solution in the first line, and the difference between the FIFO solution and the FF solution in the second line.
Example: Below are examples of input and output:
Example input: Example output:
3101013
51
1
3
1
5
6
3
2
5
1
PLEASE LET THE TIME COMPLEXITY OF THE CODE BE O(n+mk)
CODE IN PYTHON3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!