DEV Community

Aya Bouchiha
Aya Bouchiha

Posted on • Edited on

7 2

Linked List VS Array

Hello everybody, I'm Aya Bouchiha, on this amazing day, we'll talk about the difference between array and linked list.

Array VS Linked List

Array

Definition

The array is a collection of elements stored at contiguous memory of a similar data type.

  • Array elements are stored in a contiguous block of memory
  • fixed size
  • accessing directly a specific element O(1)
  • slow when performing delete and insert operations.
  • fast when it comes to finding an element (binary search)

Types of Array

  • one-dimensional array
  • two-dimensional array
  • multidimensional array

Linked List

Definition

A linked list is a linear data structure, in which the elements are linked using pointers, additionally, they are not stored at contiguous memory locations. A Linked List consists of Nodes that contain value ( data ) and a pointer to the next node in the chain. The head pointer points to the first node if the list is not empty, and the last element of the list points to null.

  • Linked List elements are stored randomly.
  • dynamic size
  • for accessing an element we need to pass all linked list elements that are preceded by the specified element O(n)
  • faster than array when It comes to performing insert and deletes operations.
  • take more extra space to store node pointers

for more information about linked lists like the time and space complexity, Linked list's advantages and disadvantages, implementation

Types of Linked List

  • Singly Linked List
  • Doubly Linked List
  • Circular Linked List

References

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
ayabouchiha profile image
Aya Bouchiha

Wow

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay