What is Array List?
29 Jun 2020Contents
What is Array List?
- Array List is a data structure that implements the list using an array.
-
Sequential Structure
- stores data in order.
Structure of Array List
- Data is stored within the node.
- Multiple data can be stored.
- Every element has its own address.
- So, the address of a particular element can be calculated.
Advantage of Array List
- It takes O(1) to find a data in a particular location.
- It is fast to access certain data using indexes.
Random access
is possible, it’s easy to access nth element.- Memory is allocated in
contiguous memory location
for its data.- It’s possible to avoid
memory overflow
or shortage of memory.
- It’s possible to avoid
- It is simple to implement.
Disadvantage of Array List
- The size of the array is
fixed
.- When the array is full, it’s not possible to add new data.
- Therefore, an
array of larger sizes
thanthe number of data to be stored
must be created, which is awaste of memory space
. - If the array is smaller than the number of data to be stored, it can cause problems.
- The time complexity of adding and deleting data is O(N).
Operations for Array List
Insertion
- If we simply add new data, add the data from the
left side of the array
sequentially. - However, if new data is added where the
data already exists
, all existing datamust be moved
.- Move the data on the right first.
Deletion
- The data on the right can be easily removed.
- However, if we remove the data in the middle, we have to
fill in the empty space
.
Get Data
- We can easily find it by using the
location of the data
we want to find.