Have you ever unironically used linked lists outside interview questions?

Have you ever unironically used linked lists outside interview questions?

Attached: 1644502320707.png (255x262, 96.63K)

Yep, but it was a very niche case (as you'd probably expect). I had a set of arrays where the position in an array would be different over the different arrays (so imagine you have 3 arrays, the first array could be at index 2, second could be at index 8 and the third could be at index 0). There's obviously a lot of different ways to do this, but a linked list is, imo, the most natural structure to use for the problem.

Can you post a code snippet of what you're talking about?
I just don't get linked lists..

I'm using a doubly linked list matrix data structure rightn now.

Sorry I can't it was work related. I can try and describe the problem more and why a linked list was the right solution for it, if that helps.

thanks for posting the picture, I'm going to watch it on loop for the next 8 hours while I code.

Yes please, I never use them and I want to start to so I appear smart

Attached: 1658605484682432.jpg (500x437, 150.13K)

4u

>hit or miss i guess they never miss huh?
>you got a boyfriend i bet he doesn't miss ya
セックス下さい

Yes.

Okay, here it goes! We had some data that looked a bit like:
[
[a,b,c,d,a,a,a,b],
[g,g,g,f,d,s,f,g,s,a,d,s],
[a,b,c]
]

Now as this data was being processed we needed to keep track of three things:
>The current value of the data in each array
>The next value of the data in each array
>If we had reached the end of the array
So why do linked lists work well for this problem? Well a linked list gives you the first two things we need to keep track of, the Head object contains the current value of the data and pointer to the next value. So without having to do any extra work, you need get two of the three things we needed, and the third comes pretty easily since you only need to check if head.next is none. Any other way of doing it would require a lot of other arrays floating around, that keep track of other bits of data.

Does that help? Or were you wanting more information on how you implement a linked list?

So basically you have an object or a structure that contains one reference to another instance of itself, and one reference to an arbitrary object. Adding an object to a linked list means creating a new instance of the list object, containing a reference to the previous instance of list object, and a reference to the object you’re adding to your list.
Imagine you’re connecting paper clips together into a long chain. The chain is the linked list, the paper clips are the link objects, and glued to each paper clip is a little paper note, those are the objects in the list.

yes, in posix signal handler related code. I can allocate a link, set it up, lock the structure (from this point on I can't use non async safe features, like malloc), insert new element (signal safe), unlock structure. They're really handy in general OSdev stuff because you can do this allocate-lock-modify-unlock pattern

I mean I read what you're saying and it makes sense, but on practice I don't get how you can iterate through two (or more) linked lists at once and comparing them
Or why linkedList1 || linkedList2 returns the smallest list, and why the AND operator returns the longest one.
Example of something I found that I was trying to make sense of!

const dummy = { next: null };
let cur = dummy;
console.log('l1 && l2', l1 && l2);

while (l1 && l2) {
console.log('l1.val', l1.val);
console.log('l2.val', l2.val);

l1.val < l2.val ? (cur.next = l1, l1 = l1.next) : (cur.next = l2, l2 = l2.next);
cur = cur.next;
console.log('cur', cur);
console.log('l2', l2);console.log('l1', l1);

console.log('cur.next', cur.next);
}
cur.next = l1 || l2;
console.log('l1 || l2', l1 || l2);

console.log('dummy.next', dummy.next);
return dummy.next;

Attached: 1657266404262.png (704x707, 917.82K)

reality is just linked lists of molecules

I'm a blockchain developer, that's all I do

Nope. Turns out vector is more useful than linked list by a great margin.

Yes (I use lisp)

holy shit this is super hot fire, thanks!

Attached: 1383086779007.png (1280x695, 456.34K)

...

I use linked lists almost every time I write code, because I primarily use Haskell.