Reprint please indicate source: http://blog.csdn.net/u010194538/article/details/51001353
3rd ChapterLinear table3.2 Definition of a linear table
linear table (list): A finite sequence of 0 or more data elements.
elements are sequential If there are multiple elements, the first element has no precursors, The last element has no successor, and each of the other elements has only one precursor and a successor.
The linear table emphasizes Limited .
In a more complex linear table, a data element can consist of several data items.
3.4 Sequential storage structure of linear tables
sequential storage structure of linear tables , which refers to the data elements of a linear table stored sequentially by a contiguous storage unit.
The description of the sequential storage structure requires three properties:
Start location of storage space: Array data, where storage space is stored.
Maximum storage capacity for linear tables: array length MaxSize.
Current length of the linear table:length.
At any given moment, the length of the linear table should be less than or equal to the length of the array.
each storage unit in the memory has its own number, which is called Address .
Complexity of Time : Its access time performance is O (1). We often refer to a storage structure with this characteristic as a random access structure.
Characteristics:
The sequential storage structure of a linear table, in which the time complexity is O ( 1)when the data is stored or read,and when inserted or deleted, the time complexity is o (n). This shows that it is more suitable for the number of elements is not very change, but more is the application of data access.
3.6 chain storage structure for linear tables
Now in the chain structure, in addition to the data element information to be stored, but also to store its successor elements of the storage address.
In order to represent the logical relationship between each data element AI and its direct successor data element ai+1 , the data element AI , in addition to storing its own information, It is also necessary to store a message indicating its direct successor (that is, the direct successor storage location). We call the domain where data element information is stored data fields,The field that stores the direct successor position is calledThe pointer field. the information stored in the pointer field is calledpointer or chain. These two pieces of information make up The storage image of the data element Ai, calledNode (node).
n nodes ( The AI's storage image) chain into a linked list, whichis the chain storage structure of the linear table (a1,a2,...,an), Because each node in this list contains only one pointer field, it is called a single-linked list.
We call the storage location of the first node in the list head pointer , The last node pointer of a linear list is "empty" (usually denoted by a null or "^" symbol).
sometimes, to make it easier to manipulate a linked list, a node is attached to the first node of a single linked list, called Head knot Point . The data field of the head node can store no information , or it can store additional information such as the length of the linear table, and the pointer field of the head node stores pointers to the first node.
the similarities and differences between the head pointer and the head knot point :
single-linked list Read, Its main core idea is " The work pointer moves back ".
single linked listinserting and deletingalgorithm, we find that they are actually composed of two parts: the first part is to traverse to find the first node, and the second part is to insert and delete nodes. It is easy to deduce that their time complexity is O (n). If we do not know the pointer position of the node I, the single-linked list data structure in the INSERT and delete operations, and linear table of sequential storage structure is not much advantage. We only need to find the pointer to position I at the first time, O (n), then simply move the pointer through the assignment, the time complexity is O ( 1). Obviously, the more frequent the insertion or deletion of data, the more obvious the efficiency advantage of a single-linked list.
Single-linked list structure vs. sequential storage structure:
3.12 Static Linked List
The list of linked lists that are described in arrays is called static Linked list ( cursor Implementation method) .
The advantages and disadvantages of static linked lists:
In general, static linked lists are designed to provide a way to implement single-list capabilities for high-level languages that do not have pointers.
3.13 Circular Link List
The circular list solves a troublesome problem: How to access all the nodes of a linked list from one of the nodes.
by changing the pointer of the terminal node in the single-linked list to point to the head node, the whole single-linked list is formed into a ring, which is called the single-cycle list of the driven by. circular Linked list (circular linked list).
3.15 doubly linked list
doubly linked list (double linkedlist) is in each node of the single-linked list, and then sets a pointer field to its predecessor node.
Summarize:
Borrow the author a word mutual encouragement: not afraid of suffering, endure hardship, afraid of hardship, hardship for a lifetime.
Big talk data Structure reading Note series (three) linear table