Interview-the difference between a linked list and an array

Source: Internet
Author: User


Related information:
1.http://blog.csdn.net/kedark/article/details/54915577
2.http://blog.csdn.net/wqsys/article/details/7656650

array:
1. Keep elements in memory for continuous storage.
2. Each element occupies the same memory.
3. Quickly access any element in the array by subscript.
4. adding, deleting an element requires moving a large number of elements.
5. Requires fast access to data, minimal or no insertion and deletion of elements, application of arrays.
6. ( Static) arrays allocate space from the stack, which is quick and easy for programmers, but with little freedom.
7. Memory footprint is fixed.

Linked list:
1. Elements are not stored sequentially in memory, and are linked by pointers in existing elements.
2. Accessing the linked list requires starting with the first element and always finding the desired element location.
3. Adding and removing an element only requires modifying the pointer.
4. You need to constantly add, delete elements, and apply linked lists.
5. The linked list allocates space from the heap, the degree of freedom is large but the application management is more troublesome.
6. The memory footprint is fragmented.

Interview-the difference between a linked list and an 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.