Sequential representation and implementation of linear tables

Source: Internet
Author: User

The sequential representation of a linear table refers to the data elements of a linear table that are stored sequentially with a contiguous set of storage cells.

Assume that each element of a linear table occupies an L storage unit and that the storage address of the first cell that it occupies is the storage location of the data element. The storage position of the i+1 data element in the linear table, loc (ai+1) and the storage location of the first Data element, LOC (AI), satisfies the following relationship:

LOC (ai+1) =loc (AI) +l

In general, the first data element of the linear table is where AI is stored

LOC (AI) =loc (A1) + (I-1) XL

LOC (A1) is the storage location of the first data element in a linear table, often referred to as the starting position or base address of a linear table. As long as the starting position of the storage linear table is determined, any data element in the linear table can be randomly accessed, so the sequential storage structure of the linear table is a random access storage structure.

Attention:

The sequential storage structure of a linear table is characterized by the proximity of two adjacent elements on a logical relationship, so that any element in the table can be randomly accessed, and its storage location is represented by a simple, intuitive formula. On the other hand, however, this feature is also a weakness of this storage structure: a large number of elements need to be moved when inserting or deleting operations.

Demo 1:

Algorithm: Sequential table merging, already sequential linear table LA and LB elements by value non-descending arrangement, merging LA and LB to get new sequential linear table LC,LC elements are also non-descending by value.

Sequential representation and implementation of linear tables

Related Article

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.