From d9f97fd2ffef13ebf616b592d22564fc11a9a01e Mon Sep 17 00:00:00 2001 From: DEBADRIBASAK <32904247+DEBADRIBASAK@users.noreply.github.com> Date: Fri, 8 Oct 2021 22:17:36 +0530 Subject: [PATCH] Add README for lists (#2421) --- DataStructures/Lists/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 DataStructures/Lists/README.md diff --git a/DataStructures/Lists/README.md b/DataStructures/Lists/README.md new file mode 100644 index 000000000..544d22277 --- /dev/null +++ b/DataStructures/Lists/README.md @@ -0,0 +1,30 @@ +## Linked List +### Description + +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. + +### Structure + +``` +class LinkedList{ + E value; + LinkedList next; +} +``` + +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: + + +### Properties +1. Linked list does not provide indexing like an array. For accessing a node at position `p` , θ(p) nodes need to be accessed. +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) +3. Unlike an array, its size is not predefined. So any number of nodes can be appended. + +### File descriptions: + +1. `CircleLinkedList.java` : A circular linked list where next pointer of last node points to first nide of linked list. +2. `SinglyLinkedList.java` : The classic case of single links. +3. `CountSinglyLinkedListRecursion.java`: Recursively counts the size of a list. +4. `detect_and_create_loop.java` : Detect a loop in linked list +5. `DoublyLinkedList.java` : A modification of singly linked list which has a `prev` pointer to point to the previous node. +6. `Merge_K_SortedLinkedlist.java` : Merges K sorted linked list with mergesort (mergesort is also the most efficient sorting algorithm for linked list). \ No newline at end of file