1. Array / List
Python uses its built-inlist class to represent arrays. Elements are stored in contiguous memory locations, allowing fast index-based access.
CRUD Operations
Code Example
2. Stack (LIFO)
A Stack is a Last-In, First-Out (LIFO) data structure. In Python, you can implement a stack cleanly using a standardlist where insertions and deletions happen only at the end.
CRUD Operations
Code Example
3. Queue (FIFO)
A Queue is a First-In, First-Out (FIFO) data structure. In Python, queues should be implemented usingcollections.deque (double-ended queue) for fast operations at both ends.
CRUD Operations
Code Example
4. Map (Dictionary)
A Map maps unique keys to values. In Python, maps are represented by the built-indict class, which uses an underlying hash table to achieve extremely fast operations.
CRUD Operations
Code Example
5. Tree (Binary Search Tree)
A Binary Search Tree (BST) is a hierarchical node structure where each node has at most two children. The left child contains values less than the parent, and the right child contains values greater.BST Node Class
To implement a tree, we define a custom node class:CRUD Operations (Average Cases)
Code Example
What’s next?
Learn about packing and unpacking values in Python to write cleaner and more readable code.Packing and Unpacking
Learn to pack and unpack collections