Linked Lists
Definition
A linked list is a linear data structure that consists of a series of nodes connected by pointers (in C or C++) or references (in Java, Python, and JavaScript).
Each node contains data and a pointer/reference to the next node in the list.
Uses
- Efficient insertion and deletion compared to arrays.
- Used to implement other data structures like stack, queue and deque.
Basic Operations
- Insertion
- Search an element
- Find length
- Reverse a linked list
- Delete an element (given a key, given a position)
- Get Nth node (from first, from last)
Problems
- Print the middle of a given linked list
- Write a function that counts the number of times a given int occurs in a Linked List
- Check if a linked list is a Circular Linked List
- Count nodes in a Circular linked list
- Convert a singly linked list into a circular linked list
- Exchange first and last nodes in Circular Linked List
- Reverse a Doubly Linked List
- Program to find the size of Doubly Linked List
- An interesting method to print reverse of a linked list
- Can we reverse a linked list in less than O(n)?
- Circular Linked List Traversal
- Delete a node in a Doubly Linked List
- Detect loop in a linked list
- Find length of loop in a linked list
- Remove duplicates from a sorted linked list
- Intersection of two Sorted Linked Lists
- QuickSort on Singly Linked List
- Split a Circular Linked List into two halves
- Deletion from a Circular Linked List
- Merge Sort for Doubly Linked List
- Find pairs with given sum in a doubly linked list
- Insert value in sorted way in a sorted doubly linked list
- Remove duplicates from an unsorted doubly linked list
- Rotate a Doubly linked list by N nodes
- Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?
- Modify contents of Linked List
- Intersection point of two Linked Lists.
-
| Circular Queue |
Set 2 (Circular Linked List Implementation) |
- Josephus Circle using a circular linked list
- The Great Tree-List Recursion Problem.
- Copy a linked list with next and orbit pointer
-
| Convert a given Binary Tree to Doubly Linked List |
Set |
- Priority Queue using a doubly linked list
- Reverse a doubly linked list in groups of given sizes
- Reverse a stack without using extra space in O(n)
- Linked List representation of Disjoint Set Data Structures
- Sublist Search (Search a linked list in another list)
- Construct a linked list from 2D matrix