What are the advantages and disadvantages of using an Array?


  1. Random access is enabled
  2. Saves memory
  3. Cache friendly
  4. Predictable compile timing
  5. Helps in re-usability of code
  6. 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.
  7. 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.
  8. 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.