You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8935eb0
Browse filesBrowse the repository at this point in the historyBrowse files
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).
-**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`.
-**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