Create a min heap using the function value for the different nodes. Create a hashmap in parallel which contains the page address as key and value as the node pointer of the heap. Whenever a page access is done, the node's function value is updated and we heapify with that node as start point. The nodes with highest value of 'f' will be at the end. During removal, remove the node at the top and insert the last node at the root location and call heapify.
One more solution though its a bit space consuming. Break all the string nodes to individual character nodes.- abhishek.verma98 May 28, 2015
a -> bc -> de -> NULL
will be converted to
a -> b -> c -> d -> e -> NULL
This becomes easy question to solve now. Check whether the linked list is palindrome or not as it contains only single character per node now.