Difference between Array and Linked List

 Difference between Array and Linked List

Hello Friends, Today we will tell you the difference between array and linked list, So let's start this guys.



Both Arrays and linked list are used for store the linear data but arrays allocate the contiguous memory location in Compile time while linked list allocate the memory in run time.

This is basic and most important difference .Now, we will read the other main difference,

  1. Array is an ordered collection of same data type but linked list is ordered collection of same type of element which is connected to each other by pointers.
  2. Array supports random access which means that we can access this directly by index.e.g. For 1st element arr[0] , for 7th element arr[6] etc. while Linked list supports sequential access which means that in linked list for access any elements/nodes we have to sequentially traverse the full list.
  3. Arrays store the elements in contiguous memory location while In linked list a new elements can be store anywhere.
  4. In Arrays, elements can access very fast and time complexity is O(1) While time complexity of linked list is O(n).
  5. In Arrays, insertion and deletion operation takes longer because memory locations are continuous and fixed but In Linked list, Insertion and deletion operation are very fast.
  6. In the Array memory allocates in compile time and it is also called Static memory allocation  But in Linked list, memory allocates in run time and it is also called Dynamic memory allocation.
  7. In Array, each elements are free and we can access it through their index value but In linked list, Each node are pointed by before and next nodes.
  8. Array can be single dimensional , two dimensional or multi dimensional while Linked list can be linear (singly),doubly and circular.
  9. In array, the size of array is specified at the time of declaration but in linked list the size of linked list is increases in run time, as new node add in this.
Note: If you Liked this difference between array and linked list , then please tell me in the comment and please share it to your friends .

Thank you!



Popular posts from this blog

Privacy Policy for Evergreen Sabji Bazar

Top 10 Engineering Colleges in India: A Comprehensive Guide in 2023

Automata Lab Assignment