Sequential representation of linear tables in data structures dynamically allocated storage structures

Source: Internet
Author: User

Sequential linear table storage structure, it is easy to implement the random access linear table I elements of operation, but to implement the delete or insert operations need to move a large number of data elements. Therefore, the sequential table is adapted to the stable linear table, such as the staff salary table and the Student status table.

1  #defineList_init_size 10//initial allocation of the linear table storage space2  #defineList_increment 2//linear table storage space allocation increment3    4typedefintElemtype;//defining abstract data types Elemtype as shaping variables5  6  structSqList7 {8Elemtype *elem;//Storage space Base9        intLength//Linear table Current lengthTen        intListsize;//Current allocated storage capacity One};

Understanding of this struct: first, the variable type of elemtype is defined externally with a TypeDef, which increases the flexibility of the code. If you want to modify the type of the storage variable later, you just need to modify the Elemtype type.

Second, the Elemtype pointer variable is used here, which is equivalent to the Elemtype elem[list_init_size when using the array, but the pointer is more flexible, as can be seen in the basic operation function of the sequential table.

Sequential representation of linear tables in data structures dynamically allocated storage structures

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.