(1) which tables are implemented?-4.

Source: Internet
Author: User

(1) which tables are implemented?-4.

Linear tables can be implemented in two ways: Sequential Representation and linked list implementation.

A linear table represents the uniqueness and continuity between data elements (such as the English alphabet ).


Sequential RepresentationIt refers to storing the data elements of a linear table in sequence with a set of sequential storage units..

LOC (A + 1) = LOC (A) + 1; // LOC (A) is the storage location of the first data element in A linear table, the starting position or base address of the linear table.

An ordered table (Sequential Representation) is characterized by the fact that elements are physically adjacent to each other in a computer to represent the logical relationship between data elements in a linear table.

You need to allocate the table size in advance. After the original size is exceeded, you need to re-allocate the continuous space.


Chained RepresentationIt refers to the data element of a linear table with any storage unit. Relationship between elements. In the linked list description, each element of the data object instance is described in a unit or node. Each node contains the location information of other nodes related to the node. Such location information about other nodes is called a chain or a pointer.

Template <class T>

Class Node



T data; // node Value

Node <T> * link; // pointer to the next Node pointed by the Node


No pre-allocation is required. Additional information needs to be stored to implement the logical relationship of the table.

Basic operations of a linear table include initializing a table, clearing a table, determining whether the table is empty, obtaining the table length, obtaining the elements in the table, obtaining the previous element of the table, and inserting the element, delete.


-- Compiled from the C/C ++ programmer interview book


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.