Skip to content

Commit d9f97fd

Browse files
authored
Add README for lists (TheAlgorithms#2421)
1 parent 9300a4e commit d9f97fd

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

DataStructures/Lists/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Linked List
2+
### Description
3+
4+
LinkedList is a data structure in which data is stored in a linear manner. It usually contains a data field and a link to the memory location of the next mode.
5+
6+
### Structure
7+
8+
```
9+
class LinkedList<E>{
10+
E value;
11+
LinkedList next;
12+
}
13+
```
14+
15+
The `next` variable points to the next node in the data structure and value stores the data. Any number of nodes can be linked in this manner. The structure will be:
16+
17+
18+
### Properties
19+
1. Linked list does not provide indexing like an array. For accessing a node at position `p` , &theta;(p) nodes need to be accessed.
20+
2. Main advantage of linked list is addition and removal of nodes near the end and beginning of lists. It can be done just by updating the link (O(1) time)
21+
3. Unlike an array, its size is not predefined. So any number of nodes can be appended.
22+
23+
### File descriptions:
24+
25+
1. `CircleLinkedList.java` : A circular linked list where next pointer of last node points to first nide of linked list.
26+
2. `SinglyLinkedList.java` : The classic case of single links.
27+
3. `CountSinglyLinkedListRecursion.java`: Recursively counts the size of a list.
28+
4. `detect_and_create_loop.java` : Detect a loop in linked list
29+
5. `DoublyLinkedList.java` : A modification of singly linked list which has a `prev` pointer to point to the previous node.
30+
6. `Merge_K_SortedLinkedlist.java` : Merges K sorted linked list with mergesort (mergesort is also the most efficient sorting algorithm for linked list).

0 commit comments

Comments
 (0)