polish OI problem help

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
kpo
New poster
Posts: 8
Joined: Tue Apr 01, 2003 6:55 pm

polish OI problem help

Post by kpo »

Can anyone help me with this problem:
http://www.oi.edu.pl/php/show.php?ac=e1 ... a/oi12/sam

Thanks.
Monsoon
Learning poster
Posts: 66
Joined: Fri Jul 23, 2004 4:42 pm
Location: Poland

Post 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.
kpo
New poster
Posts: 8
Joined: Tue Apr 01, 2003 6:55 pm

Post by kpo »

thanks, but can you please give some more hints about the algorithm? :)
misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post 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
kpo
New poster
Posts: 8
Joined: Tue Apr 01, 2003 6:55 pm

Post by kpo »

thank you! :D
Post Reply

Return to “Algorithms”