Skip to content

Commit a73908f

Browse files
committed
docs: added dbl linkedlist + refactored layout
1 parent 90eb119 commit a73908f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/dataStructures/linkedList/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ linked lists are stored across memory and are connected to each other via pointe
1717

1818
*Source: BeginnersBook*
1919

20+
## Analysis
21+
Some common operations involved in a linked list includes looking up elements in a linked list and inserting elements into a linked list.
22+
23+
Searching a linked list requires O(n) time complexity whereas inserting into a linked list from a specified index requires O(n) time complexity.
24+
25+
## Notes / Further Details / Conclusion
2026

2127
### Memory Requirements & Flexibility
2228
As a contiguous block of memory must be allocated for an array, its size is fixed.
@@ -32,8 +38,6 @@ we end up needing to store more elements at run time.
3238
However, linked list gives us the option of adding new nodes at run time based on our requirements,
3339
allowing us to allocate memory to store items dynamically, giving us more flexibility.
3440

35-
**Generally, linked list is more memory efficient and flexible than arrays.**
36-
3741
### Conclusion
3842
You should aim to use linked list in scenarios where you cannot predict how many elements you need to store
3943
or if you require constant time insertions to the list.
@@ -45,10 +49,17 @@ It would also be preferred if you are conducting a lot of look up operations.
4549
The lookup time within a linked list is its biggest issue.
4650
However, there are variants of linked lists designed to speed up lookup time.
4751

48-
### Double Linked List
52+
### Doubly Linked List
53+
54+
![Doubly Linked List](https://media.geeksforgeeks.org/wp-content/cdn-uploads/gq/2014/03/DLL1.png)
55+
56+
*Source: GeeksForGeeks*
57+
58+
This is a variant of the linked list with each node containing the pointer to not just the next note, but also the previous node.
4959

60+
Unlike the standard linked list, this allows us to traverse the list in the backwards direction too, this makes it a good data structure to use when implementing undo / redo functions. However, when implementing a doubly linked list, it is vital to ensure that you consider and maintain **both** pointers.
5061

51-
This
62+
It is also worth noting that insertion from the front and back of the linked list is a O(1) operation. (Since we now only need to change the pointers in the node.)
5263

5364
### Skip list
5465

0 commit comments

Comments
 (0)