Home > Common Problem > body text

The difference between singly linked list and multiple linked list

angryTom
Release: 2019-10-24 17:32:27
Original
8408 people have browsed it

The difference between singly linked list and multiple linked list

What is a singly linked list?

Singly linked list is a chained access data structure that uses a set of storage units with arbitrary addresses to store data elements in the linear list. The data in the linked list is represented by nodes. Each node is composed of: element (image of data element) pointer (indicating the storage location of subsequent elements). The element is the storage unit that stores the data, and the pointer is to connect each node. Point address data.

Advantages: It is simple to add and delete nodes in a one-way linked list. There will be no infinite loop when traversing. (There will be no infinite loop in both directions. If the circular linked list forgets to control it, it will easily enter an infinite loop); Disadvantage: It can only be traversed from beginning to end. We can only find successors, not predecessors, that is, we can only move forward.

What is a multi-linked list?

Multiple linked lists means that nodes in the linked list may belong to multiple linked lists. The most common one is the cross linked list. Each node has multiple pointer fields, corresponding to multiple linked lists, but inversely It is inaccurate to say that a linked list with nodes with multiple pointer fields is a multi-linked list, because the nodes of a circular linked list have two pointer fields, a predecessor and a successor, but it is not a multi-linked list.

Advantages: You can find predecessors and successors, and you can advance and retreat; Disadvantages: It increases the complexity of deleting nodes.

The difference between singly linked lists and multiple linked lists:

1. A singly linked list can only contain one successor node pointer in the node structure of the element, and cannot contain multiple pointer. A doubly linked list contains two pointers: predecessor and successor.

2. The singly linked list requires that the pointer of the first node be returned after it is built (or the pointer of the head node is used for the head node), because it can only run backward, while the double linked list can be built after it is built. Give a pointer to any node, because it can go in both directions. It doesn't matter much to know which node the pointer is. In principle, the first node shall prevail.

The above is the detailed content of The difference between singly linked list and multiple linked list. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!