JavaAlgorithms/DataStructures/Lists
2021-11-02 21:28:00 +02:00
..
CircleLinkedList.java Fix Circular linked list (#2598) 2021-10-16 16:31:24 +03:00
CountSinglyLinkedListRecursion.java Formatted with Google Java Formatter 2021-04-09 14:19:34 +00:00
CreateAndDetectLoop.java Fix incorrect file extension (Fixes: #2716) (#2717) 2021-10-27 21:56:00 +03:00
CursorLinkedList.java Add what is Cursor Linked List (#2407) 2021-10-08 19:38:08 +03:00
DoublyLinkedList.java Add doubly linked list print reverse (#2797) 2021-11-02 21:28:00 +02:00
Merge_K_SortedLinkedlist.java Formatted with Google Java Formatter 2020-10-24 10:23:28 +00:00
MergeSortedArrayList.java Formatted with Google Java Formatter 2020-10-24 10:23:28 +00:00
MergeSortedSinglyLinkedList.java Formatted with Google Java Formatter 2020-10-24 10:23:28 +00:00
README.md Fix incorrect file extension (Fixes: #2716) (#2717) 2021-10-27 21:56:00 +03:00
RemoveDuplicateNodes.java Fix package declarations (#2576) 2021-10-16 16:43:51 +03:00
SearchSinglyLinkedListRecursion.java Formatted with Google Java Formatter 2020-10-24 10:23:28 +00:00
SinglyLinkedList.java Add some useful functions for singly linked list (#2757) 2021-10-30 08:19:48 +03:00

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>{
    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. CreateAndDetectLoop.java : Create and detect a loop in a 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).