Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement