Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now

Part 2-Why Linked List/ LinkedList Vs Array | Linked List Tutorials in C#


Array and Linked list both we use to store linear data of same datatype, but array has some limitation 


      Linked List 

  1. The size of the linked list is dynamic.
  2. Ease of insertion or deletion.
  3. Linked List supports Sequential Access, which means to access any element/node in a linked list, we have to sequentially traverse the complete linked list, upto that element.
  4. To access nth element of a linked list, time complexity is O(n).
  5. In a linked list, new elements can be stored anywhere in the memory.
  6. Memory is allocated at runtime, as and when a new node is added. It's also known as Dynamic Memory Allocation.
  7. Linked list can be Linear(Singly) linked list, Doubly linked list or Circular linked list linked list.
  8. Array gets memory allocated in the Stack section.
   Array

  1. The size of the arrays is fixed, so we should have knowledge of array size in advance.
  2. Inserting and deleting data in array is difficult.
  3. Array supports Random Access, which means elements can be accessed directly using their index, like arr[0] for 1st element, arr[6] for 7th element etc.
  4.  accessing elements in an array is fast with a constant time complexity of O(1).
  5. In an array, elements are stored in contiguous memory location or consecutive manner in the memory.
  6. Memory is allocated as soon as the array is declared, at compile time. It's also known as Static Memory Allocation.
  7. Array can be single dimensional, two dimensional or multidimensional.
  8. Whereas, linked list gets memory allocated in Heap section.






Share this

Related Posts

Previous
Next Post »

Exclusive Clothing Sale On Flipkart

Get up to 50% off on our latest collection.

Shop Now