Data structure (2 linear table)

Source: Internet
Author: User

Linear tables can be divided:

Ordered linear table: An array is used as the storage structure, and logically adjacent elements are also adjacent to physical storage. You can randomly access any element based on the index. However, operations on the element must be performed on all subsequent elements of the element.

 

Single-chain table: each element is random on physical storage. Except the last element, each element points to its successor element through a pointer. Access to an element must start with the first element and be directed by the pointer to the element in sequence. Insert and delete operations on elements are highly efficient. You only need to modify the corresponding pointer.

 

Static linked list: the index of the next element is represented by the following table of data items in the previous element of the logical relationship. The storage structure is stored in arrays. Prepare an array for use in advance. If no element is added, an array element is obtained.

 

Two-way linked list:

Cyclic linked list:

 

 

Algorithm code implementation:

Linear table implementation:

Array and linked list

Int array [];

Linear table operations:

Insert, delete, search, and sort.

 

 

Special linear table:

STACK:

Stack operations:

Stack implementation:

Queue:

Queue operations:

Queue implementation:

 

Application of various linear tables

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.