Advertisement
rfmonk

heapq_heapreplace.py

Jan 13th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import heapq
  5. from heapq_showtree import show_tree
  6. from heapq_heapdata import data
  7.  
  8. heapq.heapify(data)
  9. print 'start:'
  10. show_tree(data)
  11.  
  12. for n in [0, 13]:
  13.     smallest = heapq.heapreplace(data, n)
  14.     print 'replace %2d with %2d:' % (smallest, n)
  15.     show_tree(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement