SHARE
TWEET

Untitled

a guest Oct 20th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """Module containing a priority queue implemented as a binary heap with a
  2. fast heapify method.
  3. """
  4. from basic_priority_queue import BasicPriorityQueue
  5.  
  6.  
  7. class FastPriorityQueue(BasicPriorityQueue):
  8.     """Implementation of a binary max-heap based priority queue fast heapify."""
  9.  
  10.     def _heapify(self):
  11.         """Converts the list to heap order. On average it uses
  12.         considerably fewer comparisons than inserting each item
  13.         individually.
  14.         """
  15.         index = len(self._items)
  16.         for index in range(1, len(self)):
  17.             self._sift_up(index)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top