Python Heaps-ters
summary
Introduces Python's heapq module and demonstrates practical uses of heaps beyond the basic priority-queue example, explaining how heaps let you access the min/max in O(1) and insert in O(log n) and why that matters (e.g., heapsort and finding the n smallest items in huge files). Shows how heaps work and when to choose them to solve problems efficiently, with short, practical code examples in Python.
AI-written summary · about
chapters (10)
- 0:00Heaps introduction
- 1:11Finding maximum problem
- 6:33Failed attempts without heaps
- 9:48What is a heap
- 15:37Heap implementation
- 18:10Heaps in Python
- 20:14Max-heaps and tricks
- 21:39Solution with heaps
- 22:21nlargest and nsmallest functions
- 23:24Summary
related talks
57mPython's other collection types and algorithms
57mElements of Programming Interviews in Python
20mLesser known data structures
52mPython Tips, Tricks, and Idioms
30mData Structures: A learning journey
30mAlgorithmic ideas, engineering tricks, and trivia behind CPython's new sorting algorithm
25mIs it me or Python memory management? 🤔💻
19mPython - best practices
