Difference between Array and Linked List ?



Difference between Array and Linked List ?

Array Linked List
Arrays are index-based data structure where each element
associated with an index.
Linked list relies on references where each node consists of the data and the references to the previous and next element (in case of a doubly linked list) or the next element (in case of a singly linked list).
Array provides fast and random access. Elements can’t be accessed randomly but can be
accessed only sequentially and accessing element takes 0(n) time.
Elements are stored in consecutive manner in memory. Elements can be stored at any available place as
address of node is stored in previous node.
Insertion & deletion takes more time in array as elements
are stored in consecutive memory locations.
Insertion & deletion are fast & easy in linked list
as only value of pointer is needed to change.
In array, memory is allocated at compile time
i.e. Static Memory Allocation.
Memory is allocated at run time
i.e. Dynamic Memory Allocation.
Array can be single dimensional, two dimensional
or multidimensional.
Linked list can be singly, doubly or circular
linked list.
Each element is independent, no connection with previous
element or with its location.
Location or address of elements is stored in the
link part of previous element/node.
Difference between Array and Linked List

Difference between Array and Linked List



Related Searches to Difference between an Array and a Linked List ?