You are on page 1of 1

Feature Array Linked list

Definition A data structure that stores a collection A data structure that stores a collection
of elements of the same data type in of elements called nodes, where each
contiguous memory locations, where node stores the data and a link (pointer)
each element can be accessed using its to the next node in the list
index or position
Access Time Elements in an array can be accessed in Elements in a linked list can be accessed
constant time O(1) using their index or in linear time O(n) by traversing the list
position, which makes array access from the head or tail to the desired
efficient for random access operations. position. This makes linked list access
slower than arrays for random access
operations.
Memory Một thuật toán (algorithm) được cho là Một thuật toán (algorithm) được cho là
Requirement có thời gian không đổi (constant time) với có độ phức tạp về thời gian tuyến tính
O (1) khi nó không phụ thuộc vào kích (linear time) khi thời gian chạy thuật
thước đầu vào n. Nghĩa là với mọi kích toán tăng tuyến tính với độ dài (length)
thước đầu vào n thời gian chạy thuật của đầu vào (input). Đoạn mã trên cho
toán sẽ luôn giống nhau. thấy rằng dựa trên độ dài của mảng (n),
thời gian chạy sẽ được tăng tuyến tính.
Memory Memory for an array is allocated Memory for a linked list is allocated
Allocation statically, at the time of declaration, or dynamically
dynamically nodes can be added or removed from the
Once allocated, the size of the array list as needed.
remains fixed.
Insertion and Insertion and deletion operations in an Insertion and deletion operations in a
Deletion array require shifting all the elements linked list can be performed in constant
after the insertion or deletion position, time O(1), by updating the pointers of the
which takes linear time O(n). This makes previous and next nodes to skip the
array insertion and deletion inefficient for deleted node or insert a new node. This
large arrays. makes linked list insertion and deletion
efficient even for large lists.

You might also like