Linked List — Quick Overview

What’s a data structure? Was my thought when I was first getting into coding and heard about the importance of being able to work with different data structures. The first one I encountered in my journey was an array. I thought to myself, ok simple enough. It’s a list and each entry has a designated callable spot referred to as an index yadi yada you know how arrays work. It took some time for me to realize how important these and other data structures are to my success as a developer. After all, you are always consuming some type of data in your apps. Knowing the different structures can determine the performance of your project considering that data structures dictate everything from the functions we can use to access the it, and the relationships we can derive from it. In an effort get a better understating of these data structures, we’ll take a look at the linked list in this post.

What is a linked list?

It’s kind of like an array but not really lol. It’s like an array in the sense that it is also a linear data structure but not like an array as we can not grab any element at random like with arrays and indexes. As the name suggests, the data is linked to one another in a sequence of nodes. Each node is a representation of a single data structure consisting of the data element and its pointer. The pointer is what points to the next data structure which creates a model resembling a linked chain aka our linked list. Since the first and last elements do not have pointers they can be identified as the HEAD and null respectively.

When Should You Use It?

Stacks and Queues are a good place to implement linked lists as these follow the LIFO/FIFO rule. In Stacks the order can be LIFO or FILO. To give you a visual representation, imagine a deck of cards. You can grab a card from the top(FIFO) or if your desired card is at the bottom then you will have to get through all cards on top of it to get to the bottom one. In case of queues, we can think of the order as a line at the DMV. The person who got there earlier will be served before the people that came after. The major difference between stacks and queues is in how we remove the data. In stacks, we remove what was most recently added while in queues we remove the least recently added record.

Hope this helps with getting a basic grasp on linked lists. Happy coding!

Source Reference: https://www.geeksforgeeks.org/linked-list-set-1-introduction/

https://www.freecodecamp.org/news/implementing-a-linked-list-in-javascript/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Friendly Fractals N — The numbers.. What do they mean?

Enhanced Features of SAP HANA 2.0 SP02

Everything is an object in Python

bypass user-restriction registration

Case Study: How Industry are getting benefits from AWS SQS

amazon sqs

Introducing ShowControl4J

Creating RESTful Web APIs using Flask and Python

Emacs on MacOS Catalina 10.15 in 2019

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bart Minczuk

Bart Minczuk

More from Medium

DSA: Runtime Complexity

To reverse a linked list

Basic linked list diagram

Easily convert Recursive solutions to Non-Recursive alternatives

Understanding Bubble Sort at grass root level — With examples that illustrate all edge cases