This project provides a from-scratch implementation of a Stack data structure in Python. Instead of using Python's built-in list, this implementation is built upon a custom Linked List (Node
class) to demonstrate a deeper understanding of the underlying data structure.
The stack adheres to the LIFO (Last-In, First-Out) principle.
- Linked List Foundation: The stack is built using
Node
objects, each pointing to the next, which is a fundamental concept in computer science. - Core Stack Operations: Implements all essential stack methods:
push
,pop
,top
, andisEmpty
. - Constant Time Complexity: A key feature of this implementation is that all core operations (
push
,pop
,top
,isEmpty
) are performed in O(1), or constant time, making it highly efficient. This is explicitly documented in the source code.
- Robust Error Handling: The
pop
andtop
methods could be modified toraise IndexError("pop from empty stack")
instead of returningNone
, which is a more standard and explicit way to handle errors in Python.