Is there any difference, or are they two terms for the same thing?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Although there are some similarities between arrays and lists, they are used for different purposes.
An array is a contiguous segment of memory, and a list is just a bunch of nodes, each one has the pointers to the “next” node (and also to the “previous” node, in the case of bidirectional lists).
Arrays efficiently – in O(1) – support random access (i.e. by arbitrary given index i), but deleting/inserting an element into an array is slow – O(n), because you have to move all elements after deleting/inserting element.
Lists, on the other hand, do not support efficient random access (while supporting efficient consecutive traversal), but inserting and deleting is fast – O(1).
Look at this picture:
:
and at this link for a better explanation.