class favoriteslistmtf(favoriteslist) """list of elements ordered with move-to-front heuristic "" we override move up to provide move-to-front semantics def move up(selfp) """move accessed item at position to front of list "" if !self data first)delete/reinsert self data add first(self data delete( ) we override top because list is no longer sorted def top(selfk) """generate sequence of top elements in terms of access count "" if not < <len(self) raise valueerrorillegal value for we begin by making copy of the original list temp positionallistpositional lists support iteration for item in self data temp add last(item we repeatedly findreportand remove element with largest count for in range( ) find and report next highest from temp highpos temp first walk temp after(highpos while walk is not none if walk elementcount highpos elementcount highpos walk walk temp after(walk we have found the element with highest count report element to user yield highpos elementvalue temp delete(highposremove from temp list code fragment class favoriteslistmtf implementing the move-to-front heuristic this class extends favoriteslist (code fragments and and overrides methods move up and top