Chapter II data structure linear table summarizes knowledge

Chapter two

First, the definition of the linear form, the nature and characteristics

1. Linear data element table may be widely varied, but the same linear table having the same data type n (n> = 0) a finite sequence of data elements.

The same data object, there is a relationship between an ordered pair of adjacent data elements.

Length The number of elements contained in the sequence is called the linear form, is represented by n, n> = 0;

When n = 0, represents a linear table is empty, i.e., it does not contain any element of the table.

 

2. A data element may consist of a number of data items.

  Data elements called record

  Linear table contains a large number of records, also known as file

 

Table 3. Characteristics linear

 A limited number of elements in the table (n> = 0)

 Table elements having sequential logical, ordered in the sequence of elements which have the order

 Table elements are data elements, each element is a single element

 Data type elements in the table are the same. (Means that each data element occupies storage space of the same size)

Elements in the table is abstract. (Ie, logical discussion of the relationship between the elements, regardless of whether the element represented what)

Regardless of the logical structure of the data memory 4. The data is independent of the computer.

  Logical structure data is divided into: linear and nonlinear structural configuration

Linear Structure: linear form

(Linear table is a logical structure, one showing the relationship between adjacent elements)

Nonlinear structure: collection, and tree-like structure or mesh structure

Second, the linear form of sequential storage

1. The linear form of the sequence table are sequentially stored yet.

2. sequence table allocated in advance must occupy a fixed size block of memory (a set of consecutive addresses of memory cells), data elements stored sequentially in linear form, so that the two elements adjacent locations in the logical-physical also adjacent, so addressing the insert or delete operation, an average of half a table moving element, which is quite time-consuming operation, not easy to manage storage space.

3. The sequence table is used: random access mode (read mode is a not storage, different from the sequential storage)

Table 4. The main feature of the sequence: a random access

Random Access: refers to random access time regardless of the physical location of the storage unit, the access means writing the read operation, the main computer memory such as RAM in this manner, it is called a random access memory;

Random Access: focus on access, is generally understood to read. Because read-only memory ROM, RAM can be the same as random access, but can not be a random access;

Random access memory: will be understood to be equivalent to a random access, only the RAM can; RAM and ROM memory belong, also known as main memory; CD-ROM is the first generation optical disk storage, read only, it can not write, belongs to the external memory a, also known as secondary memory, which uses a laser etching method of recording information; access mode from the point of view, the magnetic disk (a flexible disk, a hard disk) have the same properties, it is a direct access mode.

The linear form of sequential storage advantages and disadvantages:

Advantages: saving storage space

       High storage density, each node stores only data elements, accessible at random

Disadvantages: also physically adjacent elements sequentially adjacent table logic, insertion and deletion operations need to move a large number of elements, using only a single piece of the adjacent memory cell, and may produce more external fragmentation

 

 

 

First, the order table

1. deleted in order from the table element having the minimum value (assuming unique) by the function returns the value of the element is deleted. Vacated position filled by the last element, if the order of the table is empty displays an error message and quit running.

2. Design an efficient algorithm, all of the elements opposing the reverse order table, the space requirements of the algorithm complexity is O (1).

3. The table of length n order L, the preparation of a time complexity of O (n), the spatial complexity is O (1) algorithm, the algorithm deletes all data element values ​​of x in the linear form.

4. Delete the value from the table ordered sequence between a given value s and t (s claim <t) of all the elements, if s or t is unreasonable sequence table is empty or an error message and out of service.

5. Delete the value from the table in the order between a given value s and t (s and t comprises, requirements s <t) of all the elements, if s or t is unreasonable sequence table is empty or display an error message and exits run.

6. Remove all duplicate values ​​from the ordered sequence of elements of the table, that the values ​​of all elements in the table are not the same.

7. The two ordered sequence table into a new table in the ordered sequence, the results returned by the function sequence table.

 

 

Published 17 original articles · won praise 11 · views 8005

Guess you like

Origin blog.csdn.net/LOVE_Me__/article/details/82718698