ArticleslgStudy

science

Unrolled linked list

Unrolled linked list is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Unrolled linked list rather than just read about it. In short: In computer programming, an unrolled linked list is a variation on the linked list which stores multiple elements in each node. It can dramatically increase cache performance, while decreasing the memory overhead associated with storing list metadata such as references.

Unrolled linked list — main illustration
Unrolled linked list — illustration

Key takeaways

  • Unrolled linked list belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Unrolled linked list to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Unrolled linked list from memory before moving on to harder problems.

Reference excerpt

In computer programming, an unrolled linked list is a variation on the linked list which stores multiple elements in each node. It can dramatically increase cache performance, while decreasing the memory overhead associated with storing list metadata such as references. It is related to the B-tree.

Overview A typical unrolled linked list node looks like this:

record node { node next // reference to next node in list int numElements // number of elements in this node, up to maxElements array elements // an array of numElements elements, // with space allocated for maxElements elements }

Each node holds up to a certain maximum number of elements, typically just large enough so that the node fills a single cache line or a small multiple thereof. A position in the list is indicated by both a reference to the node and a position in the elements array. It is also possible to include a previous pointer for an unrolled doubly linked list. To insert a new element, we find the node the element should be in and insert the element into the elements array, incrementing numElements. If the array is already full, we first insert a new node either preceding or following the current one and move half of the elements in the current node into it. To remove an element, we find the node it is in and delete it from the elements array, decrementing numElements. If this reduces the node to less than half-full, then we move elements from the next node to fill it back up above half. If this leaves the next node less than half full, then we move all its remaining elements into the current node, then bypass and delete it.

Performance One of the primary benefits of unrolled linked lists is decreased storage requirements. All nodes (except at most one) are at least half-full. If many random inserts and deletes are done, the average node will be about three-quarters full, and if inserts and deletes are only done at the beginning and end, almost all nodes will be full. Assume that:

m = maxElements, the maximum number of elements in each elements array; v = the overhead per node for references and element counts; s = the size of a single element. Then, the space used for n elements varies between ( v / m + s ) n {\displaystyle (v/m+s)n} and ( 2 v / m + s ) n {\displaystyle (2v/m+s)n} . For comparison, ordinary linked lists require ( v + s ) n {\displaystyle (v+s)n} space, although v may be smaller, and arrays, one of the most compact data structures, require s n {\displaystyle sn} space. Unrolled linked lists effectively spread the overhead v over a number of elements of the list. Thus, we see the most significant space gain when overhead is large, maxElements is large, or elements are small. If the elements are particularly small, such as bits, the overhead can be as much as 64 times larger than the data on many machines. Moreover, many popular memory allocators will keep a small amount of metadata for each node allocated, increasing the effective overhead v. Both of these make unrolled linked lists more attractive. Because unrolled linked list nodes each store a count next to the next field, retrieving the kth element of an unrolled linked list (indexing) can be done in n/m + 1 cache misses, up to a factor of m better than ordinary linked lists. Additionally, if the size of each element is small compared to the cache line size, the list can be traversed in order with fewer cache misses than ordinary linked lists. In either case, operation time still increases linearly with the size of the list.

See also CDR coding Skip list T-tree XOR linked list Hashed array tree

References

Shao, Z.; Reppy, J. H.; Appel, A. W. (1994), "Unrolling lists", Proceedings of the 1994 ACM conference on LISP and functional programming - LFP '94, pp. 185–191, doi:10.1145/182409.182453, ISBN 978-0897916431, S2CID 3192876

External links Open Data Structures—Section 3.3—SEList: A Space-Efficient Linked List, Pat Morin

Illustrations

Unrolled linked list: In this model, the maximum number of elements is 4 for each node.
In this model, the maximum number of elements is 4 for each node.

Worked examples

Example 1 — a first encounter with Unrolled linked list

Start with the simplest possible case. Write down what Unrolled linked list claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Unrolled linked list before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Unrolled linked list ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Unrolled linked list

In research
Unrolled linked list appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Unrolled linked list in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Unrolled linked list is common in secondary-school and first-year university syllabi. It links to neighbouring topics Linked lists, so understanding it makes those chapters shorter.
In everyday life
Look for Unrolled linked list outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Unrolled linked list in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Unrolled linked list means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Unrolled linked list out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Unrolled linked list in simple terms?

In computer programming, an unrolled linked list is a variation on the linked list which stores multiple elements in each node. It can dramatically increase cache performance, while decreasing the memory overhead associated with storing list metadata such as references.

Why does Unrolled linked list matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Unrolled linked list?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Unrolled linked list.

Tags

  • Linked lists

Keep exploring