Advantages and disadvantages of sequential storage structure and chained storage structure

Source: Internet
Author: User
Tags comparison

(i) Comparison of the advantages and disadvantages of sequential storage structures and chained storage structures, as well as usage scenarios.

1 Advantages and disadvantages

① sequential storage, the storage address of adjacent data elements is also adjacent (logical and physical unification); requires that the address of the memory available storage unit must be contiguous.

Advantages: Large storage density (=1), high storage space utilization. Cons: inconvenient when inserting or deleting elements.

② chain storage, the adjacent data elements can be stored at will, but the storage space is divided into two parts, part of the node value, and the other part of the node to represent the relationship between the pointer

Pros: Easy to insert or delete elements, flexible to use. Disadvantage: Small storage density (<1), low storage space utilization.


2 Use Cases

Sequential tables are suitable for static operations such as searching, and lists are appropriate for inserting and deleting such dynamic operations.

If the length of the linear table changes little, and its main operation is to find, then the sequential table is adopted;

If the length of the linear table varies greatly, and its main operation is insert, delete operation, then the linked list is adopted.


3 comparison

Comparison of sequential tables and linked lists

Space-based comparisons

How storage is allocated

The storage space of the sequential table is statically allocated

The storage space of a linked list is dynamically allocated

Storage density = Total amount of storage/node structure occupied by the node data itself

Storage density of sequential tables = 1

Storage density of the linked list < 1

Time-based comparisons

Access mode

Sequential tables can be accessed randomly or sequentially.

The linked list is sequential access

Number of elements moved when inserting/deleting

The average order table needs to move nearly half of the elements

Linked list does not need to move elements, only need to modify pointers

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.