Page 1 of 1
polish OI problem help
Posted: Thu Jul 14, 2005 6:23 pm
by kpo
Posted: Thu Jul 14, 2005 7:20 pm
by Monsoon
I don't remember fully my solution, but you should use heap to solve this task. If you want more hints just ask.
Posted: Thu Jul 14, 2005 9:34 pm
by kpo
thanks, but can you please give some more hints about the algorithm?

Posted: Thu Jul 14, 2005 10:44 pm
by misof
The problem in this task is known under the name "offline paging".
(Paging: you've got a large virtual memory stored on the swap, a smaller physical memory you use and you move pages of data to memory whenever you need them. Paging algorithms = strategies to select a page that has to be swapped off when memory is full. Offline = you know all future requests.)
In this situation Belady's algorithm is optimal.
Idea: When you have to remove a car from the carpet (=a page from the physical memory), remove the one
that will be requested furthest in the future.
To be able to do this quicky, keep the cars that currently are on the carpet stored in a heap ordered according to the time when will the kid play with them the next time.
More on paging algorithms e.g. here:
http://dimacs.rutgers.edu/~mpal/papers/dipl.ps
Posted: Fri Jul 15, 2005 2:32 pm
by kpo
thank you!
