Answer» - Size: The size of an array cannot be ALTERED at runtime SINCE data can only be stored in contiguous blocks of memory in an array. However, due to the node structure of a linked list, its size can be altered easily since each node points to the next one such that data can exist at scattered (non-contiguous) addresses.
- Memory ALLOCATION: For arrays, memory is allocated at compile time whereas for linked LISTS memory is allocated at runtime. But, a dynamically allocated array also allocates memory at runtime.
- Memory efficiency: For the same number of elements, the linked list USES more memory due to its node structure since each node stores a reference to the next node along with the data. However, linked lists may use less memory overall compared to arrays when there is uncertainty about size or there are large variations in the size of data elements.
- Execution time: In the case of a linked list, all the previous elements must be traversed to reach any element whereas elements in an array can be accessed directly using their index. As a result, some operations such as modifying an element are faster in arrays, while some other operations such as inserting an element are faster in linked lists.
|