loading...

Arrays vs Linked Lists

tcaprioli profile image Tyler Caprioli ・1 min read

Data structures are a core concept in computer science, and knowing how to identify and utilize each system correctly is the difference between an engineer and a developer. Today I'll be comparing arrays and linked lists, two prevalent data structures.

Similarities

  • orders items sequentially
  • flexible size (if array is dynamic)

Differences

  • arrays store items next to each other in memory while linked lists items aren't
  • static arrays aren't flexible in size like linked lists are
  • arrays are better for looking up items then linked lists are
  • It's easier to perform operations on the ends of linked lists than it is on arrays

Discussion

pic
Editor guide
 

A more crucial difference is that linked lists can share structure, and this allows for efficient immutable structures.

You can think of a linked list as a tree branch, seen starting from a leaf and proceeding toward the root.