Linked List Vs. Arrays
Both Linked list and Arrays are linear data structure used to store data. The major difference between array and linked list lies in the structure of the array and linked list and how data is stored in both of them.
|Basis of Difference
|Linked list is a collection of similar type of data connected with links/pointers.
|Array is a collection of elements having same data type.
|Each node of a linked list is not stored in contiguous manner in memory.
|Array elements are stored in contiguous manner in memory.
|The size of the linked list is of variable length. It is not fixed.
|The size of array is fixed and specified at the time of declaration.
|It requires more memory because of the pointer part of the node.
|It requires less memory as compared to linked list.
|Accessing of Elements
|The elements of the linked list can be accessed sequentially. To access any element of the linked list, traversing of list is required.
|The elements of the array can be accessed randomly or directly with index position
|Insertion and Deletion Operation
|In linked list, the insertion and deletion takes less time because it does not require shifting of elements, only pointers are manipulated for insertion and deletion operation.
|In arrays, the insertion and deletion takes more time as shifting of elements is required.
- Introduction to Linked List
- Insert a New Node at the beginning of the Linked List.
- Insert a New Node at the end of the Linked List.
- Insert a New Node at the Middle of the Linked List.
- Insert a New Node at the Sorted Linked List.
- Reverse a Linked List.
- Reverse a Linked List Using Stack.
- Printing Linked List in Reverse Order without actually reversing the Linked List.
- Swap Adjacent Elements of the Linked List.
- Count All Occurrences of a Particular Node in a Linked List.
- Bubble Sort on Linked List.
- Detect a Loop in a Linked List.
- Find the Length of the Loop present in the Linked List.
- Detect and Remove Loop from a Linked List.
- Segregate Even and Odd Nodes of the Linked List.
- Delete Complete Linked List.
- Delete Nth Node of the Linked List.
- Delete without head pointer of the Linked List.
- Delete All Occurrences of particular node of the Linked List.
- Delete Alternate Nodes of the Linked List.