[Data structure] The difference and connection between abstract data types (list, linear list, linked list, array)

[Data structure] The difference and connection between abstract data types (list, linear list, linked list, array)

Remarks

2020/3/17 Tuesday
I heard that everyone has started to learn about data structures, but many people are confused by the names related to various data structures. I specifically checked a lot of information to chat with you about the relationship between various data structures.

One, the abstract data type ADT

Abstract data typeADT(Abstract Data Type) is constructed for a type of data that may have specific forms and behaviorsmathematical model. ADT is composed of values ​​and operations on them. For ADT, we are more concerned about its definition and operations, rather than how this ADT is implemented.

2. Linear structure

For data structure, we can usually be divided into linear structure and non-linear structure.
Linear structure is an abstract data type, and its characteristics are as follows:
1. Must exist in the collectiononlyA "first element" of;
2.Must exist in the collectiononlyOne of the "last element";
3. Except for the last element, other data elements haveonlyThe "successor";
4. Except for the first element, other data elements haveonlyThe "precursor".
The linear structure of the data structure refers to the data structure in which there is a "one-to-one" linear relationship between data elements. This is the characteristic of the linear structure and can also be regarded as its definition. We usually use it to judge whether a data structure is a linear structure.

Three, array (one-dimensional)

Many people think that an array is a data type rather than a data structure, because many languages ​​(c, java, etc.) have built-in array operations, but some languages ​​(such as python) do not have built-in arrays. ActuallyArray is also a data structure, Is the simplest data type, and because it meets the characteristics of the above linear structure, it is alsoIs a linear structure. At the same time, the array is used most of the time asStorage structure, Array is a sequential storage structure, which has the characteristics of one-time application for long-term use. Due to the vague definition of data structure, some people have disputes about this. Domestic forums hold their own words. I finally chose Wikipedia as a reference material. Friends who are good in English can read it for themselves.
ArrayRegarding the array, we generally don’t care about its operation, because most languages ​​provide us with the necessary operations, and it is one of our most commonly used operations, and languages ​​that do not provide arrays generally do not use arrays or have more Good data types can be used, and we don't need to implement array operations ourselves.

Fourth, the linked list (linked list)

Linked list is also one of the simplest and most common data structures, and at the same time it conforms to the characteristics of linear structure, it is typicalLinear structure. Unlike an array, the elements of a linked list can exist anywhere in the memory, and the memory is dynamically allocated, and the addresses are not continuous, which can improve the utilization of memory. There are many types of linked lists, I will not list them. In C language, pointers and dynamic allocation of memory are generally used. Of course, it can also be simulated by arrays (not real linked lists). We can also use linked lists to simulate arrays (not real arrays), from which we can find thatData structure can be simulated with each other, Part of the data structure is based on one or more easily realized data structure simulation, soSome data structures can be implemented in more than one way(All are right, each has its own advantages). For linked lists, we generally need to implement the following functions:
1. Create an empty linked list
2. Return the length of the linked list
3. Add an element
4. Return the element of the specified order
5 Find an element (first occurrence)
6. Delete the specified element
and I also put the Wikipedia related to the linked list below
Linked list

Five, list (list)

After talking about the linked list, some people will be confused when talking about the list again: "Isn't this the same thing?" I am also very confused about this, because in different people’s mouths, the meaning of list in different computer languages ​​is not the same, so what is it? I checked many domestic forums and I found that everyone uses these words very much. random. It may refer to a linked list, it may be a data type or template, or even an API interface. So I checked Wikipedia again, and Wikipedia saidList is a kind of ADT , used to represent ordered values, This is very similar to linear structure, and even higher level of abstraction than linear structure, and there are few other descriptions. The original text is as follows
List

Six, linear list (linear list)

Finally, I have arrived at the linear table. This term is used much more frequently than the list. It may even appear in some books on algorithms and data structures. It is the same as the list and does not have a clear definition. It is used in major domestic forums.Primarily as a linear form linear structure and list these two meanings used. As for foreign countries, Wikipedia does not have the term linear list, and Google's results are also useful for linking lists and linear structures. It seems that in the future, we have to distinguish this frequently used word on the basis of semantics.


Finally, to find the English of each word is to determine whether the difference is caused by different translations. Wikipedia is quoted many times to compare the different meanings of the same word at home and abroad. At the same time, using Wikipedia as a reference can reduce the influence of different opinions on different forums. There is no uniform standard for the usage of words, as long as you are used to not producing ambiguity.


Welcome to put forward your valuable opinions in the comment area

Guess you like

Origin blog.csdn.net/l1447320229/article/details/104925364