Data Structure in linear table 1

Source: Internet
Author: User

Linear table

1. A linear table (linearlist) is composed of n (n ≥ 0) data elements (nodes) A [0], a [1], a [2]…, A [n-1] finite sequence.

Where: the number of data elements N is defined as the table length = "list ". length () ("list ". length () = 0 (there is no element in the table) is called an empty table)

Write a non-empty linear table (n> = 0) as follows: (A [0], a [1], a [2],…, A [n-1])

The Data Element A [I] (0 ≤ I ≤ N-1) is just an abstract symbol. Its specific meaning can be different under different circumstances.

A data element can be composed of several data items. A data element is called a record. A linear table containing a large number of records is also called a file. This structure has the following features:There is a unique (header) data element without a precursor; there is a unique (tail) data element without a successor; in addition, each data element has a direct precursor and a direct successor data element.

2. Basic operations on Linear tables
1) makeempty (l) is a method to change l to an empty table.
2) length (L) returns the length of table l, that is, the number of elements in the table.
3) Get (L, I) is a function. The function value is the element at position I in L (1 ≤ I ≤ n)
4) Prev (L, I) takes the precursor element of I.
5) Next (L, I) gets the successor element of I.
6) locate (L, x) is a function. The function value is the position of element x in L.
7) insert (L, I, x) insert element x at position I of table l, and push the elements occupying position I and the elements following it backward.
8) Delete (L, P) deletes the element at position P from table L.
9) isempty (l) If table L is empty (Length: 0), true is returned; otherwise, false is returned.
10) Clear (l) Clear all elements
11) Init (l) is the same as the first one. The initialized linear table is empty.
12) traverse (l) traverses and outputs all elements
13) Find (L, x) find and return Elements
14) Update (L, x) to modify elements
15) sort (l) sorts all elements by the given conditions again
16) strstr (string1, string2) is used to find the first address of string2 in string1 in the character array.

3. Storage Structure of linear tables

A sequence table

B linked list

B1 single-chain table

B11 dynamic single-chain table

Static Single-Chain List of B12

B2 double-chain table

C-cycle linked list

Single-cycle linked list

Double-loop linked list

Data Structure in linear table 1

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.