LinkedList vs. Arrays

Meet Pandya
Dec 20, 2020

So, what exactly is the difference between LinkedList and Arrays?

The purpose of both of these data structures is to hold a list of items

Properties of a LinkedList

  • No fixed size, No indexes to access elements
  • Every element has a reference (pointer) to the next element
  • Must go through the whole LinkedList to add a new item
4 item LinkedList

Properties of an Array

  • Fixed size and we have indexes
  • Indexes help us pick and choose values from a given position
  • Updating an element is easy → x[2] = 10
4 item Array

As we can see, an Array element has no reference to any of it’s neighboring elements. Because we can simply access any element using indexes.

However, with a LinkedList we only have a pointer to another element. And, lot of the operations require us to traverse the list in order to get that task done.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet