Singly Linked List Practice — JavaScript Today I practiced implementing a Singly Linked List from...Singly Linked List Practice — JavaScript Today I practiced implementing a Singly Linked List from...
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Singly Linked List Practice — JavaScript
Today I practiced implementing a Singly Linked List from scratch using JavaScript.
After understanding the core structure, I challenged myself to implement additional operations rather than simply following an existing implementation.
Implemented Operations
prepend(value) append(value) find(value) delete(value) insertBefore(currentValue, newValue) insertAfter(currentValue, newValue) deleteAt(index) toArray()
Complexity Analysis
prepend() → Time: O(1) | Space: O(1) append() → Time: O(n) | Space: O(1) find() → Time: O(n) | Space: O(1) insertBefore() → Time: O(n) | Space: O(1) insertAfter() → Time: O(n) | Space: O(1) delete() → Time: O(n) | Space: O(1) deleteAt() → Time: O(n) | Space: O(1)
Key Learning
The most important part of this exercise was understanding how node references and next pointers control the structure of a Linked List.
For example, inserting a node doesn't require shifting existing elements like an Array. Instead, we update the relevant references:
Before:
10 → 20 → 40
After inserting 30:
10 → 20 → 30 → 40
This was a great exercise for strengthening my understanding of data structures, traversal, references, and algorithmic thinking.
Next challenge: Reverse a Singly Linked List from scratch.
#JavaScript #DSA #DataStructures #Algorithms #Programming #Learning
Post image
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started