Unrolled Linked List Data Structure

In this tutorial you will learn about unrolled linked list data structure.

What is Unrolled Linked List?

An Unrolled linked list is a type of link list that stores multiple elements in each node. It is also known as cache sensitive data structure. The term ‘cache’ has been taken from cache memory which is associated with CPU. A cache memory is used to store recently visited pages or data so that they can be made available for RAM immediately without accessing secondary or permanent memory. A typical unrolled linked list can be declared in C as follows.

Each node in the unrolled array contains a certain maximum number of elements. The number of elements are large enough to fill a single cache line. The position of the element in the list can be indicated either by reference or by position in the array. An unrolled linked list can be shown like following.

Unrolled Linked List in Data Structure
The operations those can be performed on an unrolled linked list are insertion and deletion.

First of all it is checked if the space is available in the list for inserting a new element. If the space is available, the element is just inserted. When the element is inserted in the array elements, the count variable is incremented by one. If array doesn’t have free space to have an element, we just create a new node, place it after the current node and move half of the elements to newly created node. It creates room/space for the new element.

When an element is deleted from the list it is simply removed from the array. If the number of elements in the array falls below N/2, we take the elements from a neighboring array to fill the array. If neighboring array
also has N/2 elements then we merge both of the arrays.

Advantages of Unrolled Linked List
1. Due to its cache behavior, the unrolled linked list performs the sequential traversal very rapidly.
2. It requires less storage space.
3. It performs the operations more quickly than ordinary linked list.
4. Indexing time O (N) is reduced to O (N/max), as we are able to process a whole node at a time instead of individual elements.

Disadvantages of Unrolled Linked List
The overhead per node for references and elements count is considerably high.

Category: DSA

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.