Data Structure------------Linear table

Source: Internet
Author: User

The collection structure-----Regardless of the relationship between the data, each data element is "equal"

Linear structure-----One-to-many correspondence, except that the first element has no precursor, and other data elements have only precursors and successors.

The tree structure-----One corresponding to multiple, except the root element, and the other data elements have a unique precursor.

The graph structure-----multiple corresponding to one element may have multiple precursors and successors

1. A linear table is a finite sequence of data elements of the same type

2, the basic operation of the linear table

<1>int Length () const

Initial conditions: Linear table already exists

Operation Result: Returns the number of linear table elements

<2>bool Empty () const

Initial conditions: Linear table already exists

Operation Result: Returns TRUE if the linear table is empty, otherwise false

<3>void Clear ()

Initial conditions: Linear table already exists

Operation Result: empty linear table ·

<4>void Traverse (void (* Visit) (elemtype&))

Initial conditions: Linear table already exists

Operation Result: the function (* Visit) is called on each element of the linear table in turn.

<5>statuscode setelem (int position,const elemtype &e)

Initial conditions: Linear table already exists, 1<=position<=length ()

Operation Result: Assigns the element of the position position of the linear table to the value E

<6>statuscode Delete (int position, elemtype &e)

Initial conditions: Linear table already exists, 1<=position<=length ()

Operation Result: Delete the element of the position position of the linear table and return its value with E (Assign the value to e), the length minus one

<7>statuscode Insert ((int position, const elemtype &e)

Initial conditions: Linear table already exists, 1<=position<=length ()

Operation Result: Insert element e before the position position in the linear table, length +1

<8>statuscode Getelem (int position, elemtype &e) const

Initial conditions: Linear table already exists, 1<=position<=length ()

Operation Result: Returns the position element of the linear table with E

Elemtype element type///

3. There are two ways to implement linear tables------sequential tables and linked lists

Data Structure------------Linear table

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.