Exploring Linked Lists: Your Beginner's Guide to Understanding Node Connections
You will learn about linked lists in this blog, including their kinds, common operations, and applications.
Concept
Definition:
-> Linear data structure with dynamic memory allocation.
Time Complexity:
-> Access -> at O(n).
-> Deletion -> at O(1).
-> Searching -> at O(n).
-> Insertion -> at O(1).
Types:
Singly Linked List: Can only be iterated from beginning.
Doubly linked list: Can be iterated from both beginning and end.
eg: https://www.geeksforgeeks.org/count-triplets-sorted-doubly-linked-list-whose-sum-equal-given-value-x/
Circular linked list:
Common Operations:
1. Delete a node
-> Delete by value is O(N).
-> Delete by address O(1).
2. Find kth node from beginning / end O(K)
3. Find cycle in a linked list
4. Reverse
5. Swap nodes
6. Copy linked list
Where a linked list is useful?
- Doubly linked list is used as a queue
- Linked list with other data structures
Linked list & Map
Linked list & Priority queue
So this is it for this article. I hope it helped you somewhere.Feel free to book 1: 1 session with me where we can discuss thing at the length.
Thank you, Have a nice day !!