← Home ← Back to /g/

Thread 106566044

20 posts 2 images /g/
Anonymous No.106566044 >>106566066 >>106566072 >>106566156 >>106566584 >>106566663 >>106566722 >>106566725 >>106567472
>need a doubly linked list
>never implemented or used such before
>google for tutorial
>receive this insanity
Isn't this like totally wrong and retarded? What the fuck is this? If you keep track of head and tail of the list then you surely won't have to traverse the list to insert at the end, right? This is why the internet sucks nowadays, I bet this is either AI generated or indian slop.
Anonymous No.106566066 >>106566070
>>106566044 (OP)
picrel only keeps track of the head tho, in that case they are right that you need to traverse the whole list even if it's kinda dumb
Anonymous No.106566070 >>106566084 >>106567597
>>106566066
Yeah I mean why would anyone ever keep track only of the head?
Anonymous No.106566072 >>106566125
>>106566044 (OP)
>then you surely won't have to traverse the list to insert at the end
You would because the data structure grows, isn't contiguous, and you have no knowledge of its length at the beginning
Anonymous No.106566084 >>106566125
>>106566070
>why would anyone ever keep track only of the head
would be good enough for a stack, but then you wouldn't need a a double linked list. idk anon they make up random shit for SEO
Anonymous No.106566125 >>106566158
>>106566072
In what kind of circumstances would I have a doubly linked list without knowing its head and tail pointers? I don't get it.
>>106566084
It triggers me that the internet is so full of shit nowadays.
Anonymous No.106566156 >>106566190
>>106566044 (OP)
>I bet this is either AI generated or indian slop
I stopped using GeeksForGeeks many many years ago when I started noticing how jeeted everything was and that one really stood out.
If I had to play devil's advocate though, it seems like they're going for a very purist explanation. I'm not sure what else to call it. They're explaining a doubly linked list as minimally as possible, so they're not giving you a practical, ready-to-use implementation with a metadata struct that holds a reference to the tail and a delete function that correctly updates that tail, and so on.
Anonymous No.106566158 >>106566196
>>106566125
The purpose of a doubly linked list instead of single is for traversing forwards and backwards

so anything you would have an unknown number of elements at compile time, and you want to be able to traverse forwards and backwards, the first google example was a browsers history, you don't know how much the user is going to store AoT, you'd want to traverse it forwards and backwards
Anonymous No.106566190
>>106566156
Forgot to mention, it's still really dumb because doing it that way they deleted a huge benefit of the structure, but I can't say I haven't been guilty of adhering to a certain set of general rules and guidelines to the point of using it as a crutch to escape having to think and end up doing something stupid like this.
Anonymous No.106566196 >>106566200 >>106566929
>>106566158
But I can keep track of the head and tail at all times, when inserting or deleting my could would update head or tail if needed. This way my could would always know bot the head and the tail pointers.
Anonymous No.106566200
>>106566196
>could
>bot
Am I having a brain aneurysm or what the fuck is this shit? I meant "code" and "about".
Anonymous No.106566584 >>106567017
>>106566044 (OP)
>implementing basic data structures yourself
only idiots do this
Anonymous No.106566663
>>106566044 (OP)
yeah there was tons and tons of indian internet slop for decades. now all the AIs are being fed the indian slop to regurgitate even worse, all so some indians can "learn" from that slop and restart the process. fucking ouroborous of garbage.
god help you for webdev shit is even worse.
Anonymous No.106566722
>>106566044 (OP)
>jeetsforjeets
The fuck did you expect?
Anonymous No.106566725
>>106566044 (OP)
Looks like doubly linked with no tail for some reason. The whole diagram is a bit wonky.
Anonymous No.106566929 >>106567448
>>106566196
then you don't need to USE a doubly linked list, the resource is merely teaching you about their existence, memory wasn't as free back when the concept was invented
Anonymous No.106567017
>>106566584
Does c even have a linked list building function? They're not really complicated enough to need one.
Anonymous No.106567448
>>106566929
Oh I do need to use it because I need to be able to effortlessly loop over the list while inserting/deleting in any position of the list.
Anonymous No.106567472
>>106566044 (OP)
Always add “before:2020” to get rid of AI results when searching with google. I’ve found that using “before:2014” gets rid of 90% of the hindu slop too, not sure why.
Anonymous No.106567597
>>106566070
For hash tables to reduce size of bucket array. But you wouldn't walk the list, you would just insert a new node at the head, as order doesn't matter. Two links are needed for O(1) removal.
See "struct hlist_head" in Linux kernel.