Home >Java >Javagetting Started >What is the difference between array and linked list

What is the difference between array and linked list

王林
王林Original
2020-12-01 09:42:0518332browse

The difference between arrays and linked lists is: 1. Arrays allocate memory statically, and linked lists allocate memory dynamically; 2. Arrays are continuous in memory, and linked lists are discontinuous; 3. Array elements are in the stack area, and linked list elements are in the heap area. .

What is the difference between array and linked list

The difference between arrays and linked lists is as follows:

(Recommended tutorial: java teaching video)

Arrays allocate memory statically, and linked lists allocate memory dynamically;

Arrays are continuous in memory, and linked lists are not continuous;

Array elements are in the stack area, and linked list elements are in the heap area;

Arrays are positioned using subscripts, the time complexity is O(1), and the time complexity of locating elements in linked lists is O(n);

The time complexity of inserting or deleting elements in arrays is O(n), and the time complexity of linked lists is Complexity O(1).

Related recommendations: java introductory tutorial

The above is the detailed content of What is the difference between array and linked list. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn