Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions