List replenishment and the difference between linked list and array

Source: Internet
Author: User

First draft: 2017-11-19 13:05:57

4 Types of linked list
  1. Non-circular single-linked list: The header node, so that the insertion delete operation is the same, do not have to specifically handle the insertion or deletion is the first position of the case.
  2. Circular single-linked list: The reference parameter is the pointer to the last node Ptail, so that you can quickly find the first node Phead = Ptail->next, but also quickly get the footer.
  3. Non-circular doubly linked list: node Q inserted after P point. Q->next = p->next; P->next->pre = q; P->next = q; Q->pre = p;
  4. Circular doubly linked list: a reference to the first or the end of a parameter.
The difference between a linked list and an array

Once the initial capacity of an array is determined, it can no longer be changed, which is appropriate for the amount of data to be processed.

Unknown the amount of data to be processed uses an array, which can cause wasted space or insufficient capacity, although dynamic arrays can be scaled up, but frequent expansion can cause significant overhead for the system.

The list capacity is unlimited, the length is the same as the number of elements, but requires additional space to store the next element of the address, the space usage is not an array.

Search by index, the time complexity of the array access element is O (1), the list is O (n)

Link list insertion and deletion time complexity is O (1), array is O (n)

The lookup value is an element of value and the velocity is the same.

List replenishment and the difference between linked list and array

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.