File tree 1 file changed +42
-0
lines changed
Data Structures/Linked Lists
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Singly Linked List
2
+
3
+ #### Description
4
+
5
+ A linear & connected data structure
6
+
7
+ #### How is it different from a typical array?
8
+
9
+ - Size of a linked list is not fixed
10
+ - Deleting and adding an element in the middle is not expensive compared to an array
11
+ - Elements can be accessed sequentially not dynamically compared to an array
12
+ - Extra memory allocation needs to be done for pointers which connects elements in a linked list
13
+
14
+
15
+ #### Example
16
+
17
+ ```
18
+ class LinkedList
19
+ {
20
+ Node head;
21
+
22
+ class Node
23
+ {
24
+ int data;
25
+ Node next;
26
+ Node(int d) {data = d;}
27
+ }
28
+ }
29
+
30
+ Here every node has a value and a pointer to the next node. The head node signifies the first element in
31
+ the list
32
+ ```
33
+
34
+ #### Code Implementation Links
35
+
36
+ - [ Java] ( https://github.com/TheAlgorithms/Java/blob/master/data_structures/Lists/SinglyLinkedList.java )
37
+ - [ C++] ( https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/Linked%20List.cpp )
38
+ - [ Python] ( https://github.com/TheAlgorithms/Python/blob/master/data_structures/LinkedList/singly_LinkedList.py )
39
+
40
+ #### Video Explanation
41
+
42
+ [ A CS50 video explaining the Linked List Data Structure] ( https://www.youtube.com/watch?v=5nsKtQuT6E8 )
You can’t perform that action at this time.
0 commit comments