数据结构链表结构体定义_展开的链表数据结构

数据结构链表结构体定义

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

在本教程中,您将了解展开的链表数据结构。

What is Unrolled Linked List?

什么是展开的链表?

linked list can be declared in C as follows. 链表 ,如下所示。
#define SIZE 50
struct node
{
	int count;
	int elements[SIZE];
	struct node *next;
};

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

Insertion 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.

插入首先检查列表中是否有空间可用于插入新元素。 如果有可用空间,则仅插入元素。 将元素插入数组元素时,count变量将增加1。 如果array没有可用空间来容纳一个元素,我们只需创建一个新节点,将其放置在当前节点之后,然后将一半的元素移至新创建的节点。 它为新元素创建空间。

Deletion 删除中
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
从列表中删除元素时,只需将其从数组中删除即可。 如果数组中的元素数小于N / 2,则从相邻数组中获取元素以填充数组。 如果相邻数组
also has N/2 elements then we merge both of the arrays.
也有N / 2个元素,那么我们合并两个数组。

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.

展开的链表的优点 1.由于其缓存行为,展开的链表非常快速地执行顺序遍历。 2.它需要更少的存储空间。 3.它比普通链表执行操作更快。 4.索引时间O(N)减少为O(N / max),因为我们能够一次处理整个节点而不是单个元素。

Disadvantages of Unrolled Linked List 展开的链表的缺点
The overhead per node for references and elements count is considerably high.
每个节点用于引用和元素计数的开销非常高。

翻译自: https://www.thecrazyprogrammer.com/2014/12/unrolled-linked-list.html

数据结构链表结构体定义

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值