diff --git a/Data Structures/Linked Lists/Doubly-linked-list.png b/Data Structures/Linked Lists/Doubly-linked-list.png new file mode 100644 index 00000000..e5beedc2 Binary files /dev/null and b/Data Structures/Linked Lists/Doubly-linked-list.png differ diff --git a/Data Structures/Linked Lists/README.md b/Data Structures/Linked Lists/README.md new file mode 100644 index 00000000..e42a0f9e --- /dev/null +++ b/Data Structures/Linked Lists/README.md @@ -0,0 +1,12 @@ +# Linked list + +A linked list is a collection of nodes which are connected to each other by pointers. A singly linked list has a pointer to the first node, and each node has a pointer to the next node. A double linked list has a pointer to the first and last node, and each node has a pointer to the next and previous node. Each node also contains data. + +Linked lists have a runtime of O(1) when inserting or reading data from the front of the list (and back for doubly linked lists), but have a runtime of O(n) when accessing a specific element in the list or searching the list. + +Images from Wikipedia under public domain. + +# Singly linked list diagram: +![alt text](Singly-linked-list.png) +# Doubly linked list diagram: +![alt text](Doubly-linked-list.png) diff --git a/Data Structures/Linked Lists/Singly-linked-list.png b/Data Structures/Linked Lists/Singly-linked-list.png new file mode 100644 index 00000000..0c241dc5 Binary files /dev/null and b/Data Structures/Linked Lists/Singly-linked-list.png differ