linked lists the trade-offs with the move-to-front heuristic if we no longer maintain the elements of the favorites list ordered by their access countswhen we are asked to find the most accessed elementswe need to search for them we will implement the top(kmethod as follows we copy all entries of our favorites list into another listnamed temp we scan the temp list times in each scanwe find the entry with the largest access countremove this entry from tempand report it in the results this implementation of method top takes (kntime thuswhen is constantmethod top runs in (ntime this occursfor examplewhen we want to get the "top tenlist howeverif is proportional to nthen top runs in ( time this occursfor examplewhen we want "top %list in we will introduce data structure that will allow us to implement top in ( log ntime (see exercise - )and more advanced techniques could be used to perform top in ( log ktime we could easily achieve ( log ntime if we use standard sorting algorithm to reorder the temporary list before reporting the top (see )this approach would be preferred to the original in the case that is (log (recall the big-omega notation introduced in section to give an asymptotic lower bound on the running time of an algorithm there is more specialized sorting algorithm (see section that can take advantage of the fact that access counts are integers in order to achieve (ntime for topfor any value of implementing the move-to-front heuristic in python we give an implementation of favorites list using the move-to-front heuristic in code fragment the new favoriteslistmtf class inherits most of its functionality from the original favoriteslist as base class by our original designthe access method of the original class relies on nonpublic utility named move up to enact the potential shifting of an element forward in the listafter its access count had been incremented thereforewe implement the move-to-front heuristic by simply overriding the move up method so that each accessed element is moved directly to the front of the list (if not already therethis action is easily implemented by means of the positional list adt the more complex portion of our favoriteslistmtf class is the new definition for the top method we rely on the first of the approaches outlined aboveinserting copies of the items into temporary list and then repeatedly findingreportingand removing an element that has the largest access count of those remaining