The company has been so busy recently that it has been working for two weeks. I wonder if you have to work overtime to meet the project.

Although I am tired from working overtime during the day and staying up late at night to write articles, I feel happy and feel a sense of achievement every time I see my reading increase and occasionally people give me a “like” after writing and Posting articles. Thank you for reading my article and giving me a thumbs up. I will try my best to write every article.

What is a linked list? What are the advantages of linked lists? What are the disadvantages of linked lists? Can anyone answer that? If you don’t know, let’s start today’s article with these three questions to learn about “linked list data structures”. (Note: If you’re not sure what a “data structure” is, look here.)

The basic concept

Brief introduction:

The data elements of a linked list are connected in series one by one. The structure formed by this string of data is called a “linked list”. It’s like a bicycle “chain.” Each data element can be called a node.

Features:

The physical storage space of linked lists in memory is discontinuous and non-sequential. Each node contains two parts, a “data domain” where data elements are stored, and a “pointer domain” where the address of the next node is stored.

Advantages:

1. Linked lists can make full use of memory space because they do not require continuity or sequence of memory space, and this feature also makes linked lists more flexible without knowing the size of data in advance.

2, linked list insert and delete data fast, only need to modify the adjacent node pointer field on the line.

Disadvantages:

1. In addition to storing data, each node also needs to store the address of the next node, thus occupying large memory space.

2. Linked lists cannot randomly access an element like indexed data structures, but only traverse from the first or last node of the linked list every time an element is searched, which increases the consumption of query data.

Classification:

One-way linked list: a linked list that stores only the address value of the next node.

Bidirectional linked list: not only stores the address value of the next node, but also stores the address value of the last node.

Circular list: A linked list connected end to end.

Summary: Use linked lists when the amount of data is uncertain and there are too many deletion and modification operations. Avoid linked lists when most of the operations on the data are queries. Reasonable use of linked list structure can greatly improve the efficiency of the program.

Today’s article only introduces the theory of linked list data structures, and I will write several articles on implementing linked lists in code.

Look all finished, click “like” and then go! The latest update is not stable, I hope you can understand! If there is any problem in the article, I hope you can point it out and I will correct it in time!