Array vs List in C++

Array and List are both data structures used for storing data but arrays store data of the same type whereas List stores data of different types.

The differences between an array and a list in C++ are listed in the table below:

ArrayList
All the elements in an Array are of the same data type.
A List can contain elements of different data types.
It stores the element in a contiguous memory location.
It stores the element randomly at any address in the memory.
Memory size is fixed in Array while declaration and it cannot be altered at run time.
List utilizes dynamic memory, the memory size can be altered at run time.
In Array operations like insertion, deletion, etc., takes more time.
In list operations like insertion, deletion, etc., take less time than arrays.
Memory is allocated at compile time.
Memory is allocated at run time.
With the help of indices, it is easier and faster to access the element in an Array.
Accessing elements in the list is time-consuming as we have to start traversing from the first element.
Memory utilization is ineffective in arrays. For example, if the size of an array is 6 and contains only 3 elements, the rest of the space will be wasted.
Memory utilization is effective in the list, as it can be allocated or deallocated at the run time according to our requirement.