Never use linked lists

>never use linked lists

Attached: rel.jpg (306x306, 68K)

>using the brainlet version of array
baka

They're faster for some stuff.

Why are you gay OP?

for example?

lru cache

Vectors

And the windows scheduler.

enjoy your overhead reallocating and copying values when you run out of space.

Most vector implementations that I see use growable arrays. They grow at a fixed rate (1.5x or 2x) so the cost is amortized.

Amortized isn't end all be all if you want consistent timings.
Maybe non-amortized takes 0.5t which enough to meet desired framerate while amortizedis 0.25t with 1t spike that causes jitter.

>implying I didn't deamortize it

You can deamortize most things with a constant factor overhead.

Every language has its own implementation of linked list that you probably used before (e.g. list in python or array in PHP) without knowledge.

>uni data structures class
>have to turn in final project within the week
>can't into linked lists no matter how hard i try
Is this the end of the road for me?
Should I give up the dream?

Tbqh linked lists are very basic data structures. Do you not understand pointers?

>list in python
>linked list
What wacky interpreter are you using?

Attached: a4234c68144db0ac544cb0f052b2372f.jpg (770x770, 67K)

Nigger it's literally a virtual chain. Each link of the chain is a node with data, and it has references to the next and previous link. Whenever you're making operations, think of a physical chain and how it'd work.

What is there to figure out?

It's literally the most basic type of data structure. I could get you being at this level and not understanding something like AVL trees fully, but how the fuck do you not understand the concept of a chain of nodes with data inside them where each one has a pointer to the next member (and the previous member if it is doubly linked)? You can easily draw it and get it in like 10 seconds. It's not that hard nigger.

Attached: Kentaro Miura (三浦建太郎).jpg (490x415, 54K)

>It's literally the most basic type of data structure.
That would be the humble stack.

>i don't understand how chains work
What?

NO.
Datastructures are not part of a language. In some languages it is. But that sucks. Should at least be in a seperated lib.

True. A linked list is still basic as fuck though. There's no reason you should have trouble implementing it.

While it's true that I'm not very used to pointers, I think the pointers needed for a linked list are pretty simple, an initial one which points to the next, etc, etc,. until the last points to NULL, it's just doesn't click for some reason.

a priority queue would be better for caching. Linked lists are great for inserting, but horrible for searching through. If you need to search, use a hash table

Nice bait

Fucking smug bastards, it's a linked list of a linked list with recursion, how the fucking I am supposed to jump from adding nodes manually to that shit? It just fucking breaks

A stack is already an abstraction.

That's essentially a 2D matrix (granted no random access so not exactly, but for all intensive purposes) they are the same. Are you too retarded to imagine what a matrix looks like?

I have seen the movie the matrix. Does a matrix look like in the movie?

your so randum and funny lel

addNode(head, newNode);
const addNode = (root, nodeToAdd) => {
while(root.next != null) {
addNode(root.next, nodeToAdd);
}
// if you make it here then you are at the last node
root.next = nodeToAdd
}

Just think of it as walking node by node until you hit the end, and then add it. The recursive solution is a lot easier than the iterative one. It's a lot easier to add a node to the front of the list than the end

addNode(head, newNode);
const addNode = (root, nodeToAdd) => {
nodeToAdd.next = head;
// update the head pointer to nodeToAdd or else everything will be garbage collected
head = nodeToAdd;

}

It's a good rule of thumb for brainlets. Of course there are cases where special linked lists are the most optimal, but vectors WILL perform better in 90% of cases.

lul an answer, this is clearly bait. Nobody can be this retarded and still go to uni. A literal 10 year old can figure out as much as this.

99% of data structures were made obsolete by hash table.

Hash table is an abstraction you fucking moron.

Abstraction of what, retard?

embedded c is not modern c

c is not modern

No, for implementing a LRU cache you have a hash table + linked list.
Heap/priority queue doesn't help.

No an associative array is an abstraction.

Thank you. I keep hearing people talk about "linked lists" but I never bothered to look it up.

t. c fag

Based Lua fag

This. Arrays and hash tables are all you really need.

How do you in less than linear time pick out all values between two values from a hash table or an array?

>c fag
>doesn't know about linked lists
Reading the first paragraph of K&R doesn't make you a C expert. This is basic 1st or 2nd year computer science shit.

>linked list of a linked list with recursion
Literally worthless in industry. Why do universities do this shit?
t. MS CS and 10 years experience

>we have decided not to proceed with your application, user

>how do you take out all the values without looking at all the values

Attached: brainlet.png (413x549, 71K)

Linked list is just a tree with down's syndrome. Trees are useful when you need a collection that should always be sorted.

Only when A and B are max and min of the set

Linked lists are really comfy.
They're way better for functional programming and when you want to work with immutable structures, because modification doesn't require you to copy the entire element.
Also technically single operations like inserting in the middle, but that benefit gets destroyed by not being in a contiguous place in memory.

It's a good way to make sure students grasp how pointers and recursion work.

Link lists are suitable for any task that requires O(1) deletion anywhere in the list. The ear clipping algorithm can go from O(n^3) to O(n^2) just by using a doubly linked list.

Deleting shit is usually a huge pain in the ass without linked lists.

Based Forth chad cucking the virgin Lispers

Haskell uses linked lists of UTF32 characters to represent strings

Can you sort a linked list Jow Forums?

Attached: sorting_graphs.png (600x371, 10K)

How large does a linked list have to be before bubble sort gets slower than quick sort?