Data structure study notes _02 ——Introduction/Storage Structure

Storage structure

The storage mechanism is the relationship between the three pieces of logical structure storage structure operation.
Operation definition—>>> logical structure----->>> (mapping) storage structure <----> operation realization

To store the data type in the computer, it is necessary to store each data element and the logical relationship between the data elements

1. sequential storage structure
using a group of memory cells to store all the data elements and logic elements of adjacent memory unit also adjacent
sequentially stores main advantages: save memory
storage unit for storing data assigned to the element value

Its storage address is LOC (element) = first element first address + (element-1) X.
The main disadvantage of sequential storage of a single element occupied by each element is that it is not easy to modify. It may be necessary to move a series of elements when inserting and deleting elements. The element of
2. Chain storage structure
Sequential storage structure requires all elements to be stored adjacently, so they need to occupy a continuous storage space, while the linked list storage structure is not like this, each node is stored separately, without occupying a whole block of storage space, in order to show the relationship between the nodes for each additional node pointer field for storing a storage address of the neighboring node
- - -
advantages : easy to modify, when the insertion and deletion operations, only need to modify the node Pointer field, no need to move the nodes.
Disadvantages. Compared with the sequential structure, the main disadvantage of the chain storage structure is the lower utilization of storage space, because part of the storage unit allocated to the data element is placed in the logical relationship between the nodes. Adjacent nodes are not necessarily adjacent in the memory. Therefore, the linear structure stored in this method cannot randomly access the nodes.

3. Index storage structure The
index storage structure is to create an index table of attachments while storing data (called the main data table). Each item in the index table is called an index item. The index item is generally
(keyword, corresponding address) )
In the index table, the orderly arrangement of all key elements (such as increasing) The corresponding address of each key is the storage address in the key element’s record data table as shown in the
figure:
(Index table) ------- ------------- >>>>> (Master Data Sheet)

 地址   关键字    对应地址                   地址      学号    姓名   分数
 100   201201    100                             100   201201  王实    85  
 - - - 


Advantages and disadvantages The advantage of the index storage structure is that the search efficiency is high, and the disadvantage is that the index table is established, which increases the time and idle overhead

4. Hash (hash) storage structure

The hash storage structure determines the storage address according to the key of the element. The specific method is to use the key of the element as an argument, and calculate the corresponding function value through a hash function H (key) (or hash function) , And then use the function as the storage address of the element.
For the previous logical structure Score, if the hash table length m = 6 (storage unit 0-5), the number of records n = 5 and
the student number as the independent variable, select the hash function into
h (Student ID) = Student ID-201201

                     哈希

Guess you like

Origin blog.csdn.net/m0_46179894/article/details/109188137