Skip to content

Commit 8935eb0

Browse files
committed
docs: add CHANGES-MADE.md documenting Linked List implementation
- Documented core logic for Node and LinkedList classes - Explained testing strategy for edge cases (empty lists, middle removal) - Traded extra memory space to achieve O(1) time (constant speed).
1 parent dd21292 commit 8935eb0

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changes Made: Linked List Implementation
2+
3+
## 1. Core Logic (`linked_list.py`)
4+
- **Node Class**: Created a `Node` class to act as the building block of the list. Each node stores a `value` and has pointers for `next` and `previous`, allowing for bi-directional traversal.
5+
- **LinkedList Class**:
6+
- Implemented `push_head(value)`: Adds a new node to the beginning of the list in **O(1)** time.
7+
- Implemented `pop_tail()`: Removes and returns the value from the end of the list in **O(1)** time. Includes logic for empty lists and single-node lists.
8+
- Implemented `remove(node)`: Removes a specific node from the list and re-wires the surrounding nodes' pointers. Handles edge cases where the node is the current `head` or `tail`.
9+
10+
## 2. Testing & Verification (`linked_list_test.py`)
11+
- **Middle Removal**: Added `test_remove_middle` to verify that when a node in the center of the list is removed, the nodes ahead and behind it correctly link to each other.
12+
- **Edge Case - Empty Pop**: Added `test_pop_empty_list` to ensure the program returns `None` rather than crashing when attempting to remove from an empty list.
13+
- **Edge Case - Null Removal**: Added `test_remove_none` to verify the `remove` method handles `None` inputs gracefully.
14+
15+
## 3. Technical Trade-offs
16+
- **Space vs. Time**: Used a Doubly Linked List structure, trading slightly more memory (for the `previous` pointer) to achieve faster removal and tail-access times **`O(1)`**.

0 commit comments

Comments
 (0)