Data structure: definition and operation of linear table

Source: Internet
Author: User

Definition of a linear table:

A linear table is a linear structure, it is a finite sequence containing n≥0 nodes, in which nodes have and only one starting node (the first element) has no precursor but there is a successor node, and there is only one terminal node (last nodes) without successor but there is a precursor node, All other nodes have and have only one precursor and one successor node. Generally, a linear table can be expressed as a linear sequence: K1,k2,..., kn, where K1 is the starting node and the KN is the terminal node.

The above definition can be remembered with the following image

A pair of ordered sequences (A,b,c,............ Z)

Figure is shown as

(^,a (First node, there is no precursor but there is a successor node), B,c ... (All other nodes have and have only one precursor and one successor node) ... Z (last node, no successor but there is a precursor node), ^)

Summary: All conforming to the characteristics of the above diagram can be considered as linear table.

The difference between the sequential representation of linear table and the expression of chain

Order table

The storage diagram is as follows

Characteristics:

One, logically adjacent data elements, physical storage location is also adjacent. (Logos consistent)

Second, the storage space of the sequential table needs to be allocated beforehand.

Advantages:

(1) The method is simple, each kind of high-level language has the array, easy to realize. (Language versatility)

(2) There is no need to add additional storage overhead to represent the logical relationship between nodes. (Memory Savings)

(3) Sequential table has the characteristic of random access by element ordinal number. (Logos consistency)

Disadvantages:

(1) when inserting and deleting in the order table, the average moving table is half of the elements, so it is inefficient for n large order table. (Operation low Efficiency)

(2) The need to allocate large enough storage space, the estimate is too large, may lead to a large number of sequential table idle, the advance allocation is too small, and will cause overflow. (Memory retention)

Chained table

The storage diagram is as follows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.