Linked List and Listlessness

Akil Griffiths
3 min readNov 22, 2020

--

I was thinking about implementing a feature in an app I’m working on. I was going to cycle through a list of names, I was wondering if I should use an actual list, a linked list. My first thought is just use an array and I probably will, but I believe it is worth it to find out why I don’t want to use a linked list. Learn a little more so I could code with confidence.

When I started to dabble in algorithms I saw my first linked list. It looked strange, it still looks strange. From what I gathered linked list are good for stacks and queues. What I want to implement is probably like a queue, so I can’t rule it out just yet. According to this article, the strength of ll is insertion and deletion. Nodes don’t have indexes so they don’t have to be renumbered, they’re just welcomed in.

It doesn’t matter where that node wants to be there is a place for them, no shuffling necessary. That is nice, but I feel the splice method works pretty well. I just have to give it… I just have to know exactly where I want to use it. That’s what they mean by easier for insertion and deletion. The insert method finds the insertion point and just starts making connections. For the splice method without know the index, you’d have to loop through the array, and then find the index, and then use the splice method, and finally the array is reorganized.

I think I understand why you would want to use a ll in certain situations. Is that it’s only strength? From what I gathered more or less yes. There seems to be a consensus that it is good for stacks and queues because of its ease of insertion and deletion. I want to say that is all but, queues are used a lot. I remember playing some online mmos and being in a queue to get in a server. I think(don’t quote me on this) queues are used when you download anything. Might be more accurate to say a ll would probably be useful in these situations that I have experienced.

What does this mean for me? Am I going to go with a linked list or an array? I plan on randomizing and doing other functions to the list. Even though I have an array bias, the evidence clearly says I definitely should use an array. I at least came a way with a bit more understanding and an appreciation of the ll. Don’t think I’ll use it anytime soon but who knows what the future holds.

Sources

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

--

--

Akil Griffiths
Akil Griffiths

No responses yet

Write a response