📜  单向链表和双向链表的区别

📅  最后修改于: 2021-09-08 14:53:36             🧑  作者: Mango

单向链表简介:单向链表是一组节点,其中每个节点都有两个字段“数据”和“链接”。 “数据”字段存储实际信息,“链接”字段用于指向下一个节点。基本上“链接”字段只是地址而已。

链表

双向链表简介:双向链表(DLL) 包含一个额外的指针,通常称为前一个指针,以及存在于单向链表中的下一个指针和数据。

dll

单向链表 vs 双向链表

Singly linked list (SLL) Doubly linked list (DLL)
SLL has nodes with only a data field and next link field. DLL has nodes with a data field, a previous link field and a next link field.
linkedlist dll
In SLL, the traversal can be done using the next node link only. In DLL, the traversal can be done using the previous node link or the next node link.
The SLL occupies less memory than DLL as it has only 2 fields. The DLL occupies more memory than SLL as it has 3 fields.
Less efficient access to elements. More efficient access to elements.

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程。