Data Structures
Specialized collections and algorithmic data structures. Master double-ended queues, immutable named records, specialized dictionaries, and min/max priority heaps.
Chapter Lessons
Deque
A double-ended queue (`collections.deque`) is a sequence-like container designed for fast, O(1) time complexity insertions and deletions from both ends.
Namedtuple
A named tuple (`collections.namedtuple`) is a factory function for creating tuple subclasses with named fields.
Ordereddict
An `OrderedDict` (`collections.OrderedDict`) remembers the order in which entries were added, like a regular `dict`. Its distinguishing feature is that it also provides methods for changing and removing entries by their position.
Defaultdict
A `collections.defaultdict` is a subclass of the built-in dictionary (`dict`) that automatically initializes missing keys with a default value.
Heap
A heap is a specialized tree-based data structure that satisfies the heap property: in a min-heap, every parent node is smaller than or equal to its children, while in a max-heap, every parent is greater than or equal to its children.