- Random access is enabled
- Saves memory
- Cache friendly
- Predictable compile timing
- Helps in re-usability of code
- Addition and deletion of records is time consuming even though we get the element of interest immediately through random access. This is due to the fact that the elements need to be reordered after insertion or deletion.
- If contiguous blocks of memory are not available in the memory, then there is an overhead on the CPU to search for the most optimal contiguous location available for the requirement.
- Now that we know what arrays are, we shall understand them in detail by solving some interview questions. Before that, let us see the functions that Python as a language provides for arrays, also known as, lists.
- append() – Adds an element at the end of the list
- copy() – returns a copy of a list.
- reverse() – reverses the elements of the list
- sort() – sorts the elements in ascending order by default.