- Preallocates all needed memory up front and wastes memory space for indices in the array that are empty.
- Fixed size: The size of the array is static (specify the array size before using it).
- One block allocation: To allocate the array itself at the beginning, sometimes it may not be possible to get the memory for the complete array (if the array size is big).
- Complex position-based insertion: To insert an element at a given position, we may need to shift the existing elements. This will create a position for us to insert the new element at the desired position. If the position at which we want to add an element is at the beginning, then the shifting operation is more expensive.
Dynamic array (also called as growable array, resizable array, dynamic table, or array list)
initially start with some fixed size array. As soon as that array becomes full, create the new array double the size of the original array.
Note: Not efficient as it can lead to lot of memory waste
No comments:
Post a Comment