Data Structure _ Linear Table _ sequential/chained storage advantages and disadvantages comparison

Source: Internet
Author: User
Tags comparison

Storage Allocation Method:

1. Sequential storage structure stores data elements of linear tables at once with a contiguous storage unit

2. Single-linked list adopts chain storage structure, and the elements of linear table are stored with a set of arbitrary storage units.

Time Performance:

1. Find: Sequential storage structure O (1)

Single-linked list O (n)

2. Insert and delete: Sequential storage structure requires an average of half of the moving table elements, the time complexity is O (n)

The time complexity of inserting and deleting a single linked list is only O (1) After finding a pointer to a position

Space performance:

1, the sequential storage structure to pre-allocate storage space, divided into a large waste, sub-small easy to cause overflow

2, single-linked list does not need to implement allocation of storage space, as long as there is free space can be temporarily allocated, the number of elements is not limited


In short, the sequential storage structure of the linear table and the single-linked list structure each has its advantages and disadvantages, can not simply say which good, which is bad, need according to the actual situation, to balance the use of which data structure to meet and achieve demand and performance.

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.