Data Structure (in Python)

Recently, I have been re-learning Python in my spare time, and I want to write a blog (or blogs) to document something new to me. Stack Surprisingly, there’s no stack type in Python. There are three ways to implement a stack in Python. Check out How to Implement a Python Stack: list collections.deque queue.LifoQueue List List is built upon blocks of continous memory. To implement a stack: >>> stack = [] >>> stack.append(1) >>> stack.append(2) >>> stack.pop() 2 >>> stack.pop() 1 Deque A deque is implemented as a doubly linked list. ...

June 8, 2025