[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
>2016 >falling for the linked list meme
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 1
File: graph.png (5 KB, 483x291) Image search: [Google]
graph.png
5 KB, 483x291
>2016
>falling for the linked list meme
>>
>>55028747
>not just storing a reference to the last element to make appending constant time
>>
>>55029668
this
>>
>>55029668
This but still most of the time might as well use an array
>>
>>55029668
>allocating memory per link is fast as long as you do it at the end
>>
>>55029858
>copying the whole array onto a larger one is faster than allocating a new node
>>
What's the difference between an ArrayList and a LinkedList? Thought they were the same. Or is an ArrayList actually a vector or something?
>>
>>55029668
Array append already is (amortized) constant time because it uses a geometric progression for allocation sizes.
>>
>>55029951
ArrayList is like vector in C++.
>>
>>55030083
Hows about Java?
>>
>>55030113
It works like a linked list but uses a dynamically resizable array to store things. A java LinkedList uses node objects to store things/reference nodes.
>>
>>55029668
As others have mentioned, array lists have amortized constant time append without having to remember the end.

They also have muchmuch better density and memory locality, so many fewer cache misses and page faults when working with them.

Linked lists were ok back in the 80's when PC's didn't have caches or virtual memory, but their main purpose nowadays is as baby's first pointer-based data structure in CPSC 101.
>>
mem
>>
>>55029951
A linked list stores every node in random non-contiguous locations in memory. This makes memory fetches slower because storing nodes in random memory locations isn't cache friendly. Arrays have much faster access times because cpu and ram can fetch local data faster.

My response is really an oversimplification and you should really read a computer architecture book if you want to know more.
>>
can /g/ sort a linked list on this whiteboard
?
Thread replies: 15
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.