Singly, Doubly and Circularly Linked Lists(SLL, DLL, SCLL, DCLL) — Data Structures

What are Linked Lists?

Linked Lists are a type of data storage, in other words, it simply stores and organizes your data. This data can be almost anything, from integers to strings, and even objects.

What are they used for?

They can have a lot of different uses, but one that helped me understand was a ‘sequential’ system. Let's use Youtubes autoplay feature as an example. The data could be the video information, providing the link that will play the video. Then when it is done it will look at the address part of the node to find the next node containing a video. And the process continues, jumping from one video to the next.

Singly Linked Lists

Both of the above examples work as a Singly Linked List. This means that each Node consists of data and ONE address, which just states the next address. We can think of these nodes as having addresses 1,2,3,4 which makes the order clear but it could be 3,7,13,3000 and as long as position 3 has the address for position 7, those two are in order, where the address 3 is the first Node and 7 is the second Node. The address numbers don’t actually have to be in any order, they are just a reference.

Singly Circularly Linked Lists

If you understand SLL, understanding SCLL should be easy. The only difference between the two is the last Node’s address. If you look at the below example, the last Node’s address pointer is the first Node’s position, 1001.

Doubly Linked Lists

A DLL is the same as a SLL, except it stores 2 addresses instead of 1.

Doubly Circularly Linked Lists

The final of the three, which incorporates all the features into one, is the DCLL. This stores the same things as a normal DLL but instead of having the null value in the start and end, those will point to each other to make it circular, just like the SCLL. That’s a lot to take in, let’s take it piece by piece.

Conclusion

There are many different structures to use, and they all have their purpose depending on the app you are aiming to make. Despite the features mentioned, there are also time signatures and space differences to also consider when deciding which one to use. Happy Coding!

--

--

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