Experiment 3 summarizes five data structures of linear tables (sequential list, singly linked list, double linked list, static linked list, indirect addressing)

Sequence table: A sequence table is a segment of storage units with consecutive addresses that sequentially stores the data elements of a linear table, generally implemented with a one-dimensional array; it is a data structure suitable for the number of known data elements or the number of data elements does not change much. The storage structure of the data structure is sequential storage and random access when accessing. So the time complexity of bitwise lookup is O(1). When the number of unknown data elements or the change of data elements is too large, using the sequence table will cause a lot of space waste.


Singly linked list: A singly linked list uses a set of arbitrary storage units to store the elements of a linear table. This set of storage units can be continuous or discontinuous, and can even be scattered anywhere in the memory. The singly linked list has a data field (data) (stores the data information of the node) and a pointer field (next) (points to the next node), and also has a head pointer (first); it is a dynamic storage allocation, in the data When the elements change greatly, the space waste phenomenon can be reduced compared to the sequence table. But the singly linked list is sequential access, that is to say, the time complexity of searching by value or by bit is O(n).


Double linked list: Double linked list is similar to singly linked list, the basic operations are almost the same. However, compared with the singly linked list, the doubly linked list has one more pointer field (prior) pointing to the predecessor node. Similar to a singly linked list, a doubly linked list is generally uniquely determined by the head pointer; in practical applications, a circular doubly linked list with a head node is often used. In theory, a circular doubly linked list can achieve random access.


Static linked list: An array is used to represent a singly linked list, and the subscript of the array element is used to simulate a pointer to a singly linked list. The static linked list consists of two fields: the data field stores the data element, and the next field stores the subscript of the element's successor element, which belongs to static storage allocation. The advantage of static linked list over sequential list is that there is no need to move subsequent elements during insertion and deletion operations, which optimizes the insertion and deletion of sequential lists. Disadvantages: It does not solve the problem that the table length is difficult to determine caused by continuous storage allocation.


Indirect Addressing: Indirect addressing is a method of combining arrays and pointers, which changes the location in the array that stores a data element to store a pointer to that element. When the space occupied by each element is large, it is much faster than the insertion operation of the sequential table. The indirect addressing of the linear table maintains the advantages of random access of the sequential table, and improves the time performance of the insertion and deletion operations, but it still does not solve the problem that the table length is difficult to determine caused by the continuous storage allocation.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325600843&siteId=291194637