Skip to main content

Command Palette

Search for a command to run...

Arrays VS Linked List

Understanding difference between these linear data structures.

Published
•1 min read•View as Markdown
T

I am a college student and eager to share my knowledge and experiences with other fellow coders. Lets connect and enhance our Knowledge!!

The easiest way to understand linked lists is perhaps by comparing linked lists with arrays.

Linked lists consist of nodes, and is a linear data structure we make ourselves, unlike arrays which is an existing data structure in the programming language that we can use.

Nodes in a linked list store links to other nodes, but array elements do not need to store links to other elements.

Linked List:

  • Data Structure: Non-contiguous

  • Memory Allocation: Typically allocated one by one to individual elements

  • Insertion/Deletion: Efficient

  • Access: Sequential

Array:

  • Data Structure: Contiguous

  • Memory Allocation: Typically allocated to the whole array

  • Insertion/Deletion: Inefficient

  • Access: Random