Skip to content

Commit 1fa28e2

Browse files
committed
added linked lists in data structures
1 parent 7d2e8bc commit 1fa28e2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## 3. Linked Lists
2+
A **Linked List** is a linear data structure consisting of nodes, where each node contains a data part and a reference (or link) to the next node in the sequence.
3+
4+
### Key Characteristics
5+
- Nodes are stored non-contiguously in memory.
6+
- Elements are linked using pointers, allowing efficient insertion and deletion.
7+
8+
### Types of Linked Lists
9+
- **Singly Linked List**: Each node has a single link to the next node.
10+
- **Doubly Linked List**: Each node has links to both the previous and next nodes.
11+
- **Circular Linked List**: Last node links back to the first node.
12+
13+
### Common Operations
14+
- **Insertion**:
15+
- At the head, tail, or a specific position.
16+
- Complexity: \(O(1)\) for head or tail (if tail pointer exists), \(O(n)\) for arbitrary position.
17+
- **Deletion**:
18+
- Removing an element from head, tail, or specific position.
19+
- Complexity: \(O(1)\) for head or tail, \(O(n)\) for arbitrary position.
20+
- **Traversal**: Accessing elements sequentially.
21+
- Complexity: \(O(n)\)
22+
- **Searching**:
23+
- Finding an element.
24+
- Complexity: \(O(n)\)
25+
26+
### Applications
27+
- **Dynamic Memory Management**: Efficient for varying data sizes.
28+
- **Implementing Stacks and Queues**: Using linked lists as the underlying data structure.
29+
- **Sparse Matrices**: Efficiently storing and accessing non-zero elements.

0 commit comments

Comments
 (0)