Arrays-Advantages and Disadvantages explained

arraysAdvantages of Arrays and Disadvantages

Advantages of Arrays (Static allocation): Some of the advantages of using arrays are:

1. Data accessing is faster: Using arrays, we can access any data item efficiently just by specifying the index of that item, For example, we can access ith item in the array A by specifying A (i). The time taken to access the data in a (0) and time taken to access the data in a (10000) is same.

2. Simple: Arrays are simple to understand and use.

Disadvantages of Arrays: Even though arrays are very useful data structures, there are some limitations due to sequential and static allocation techniques. The limitations are:

1. The size of the array is fixed: In static allocation technique, a fixed amount of memory is allocated before the start of execution for static arrays and during execution for dynamic arrays. The memory required for most of the applications often cannot be predicted while writing a program. If more memory is allocated and the application requires less memory, it results in wastage of memory space. If less memory space is allocated and if the applications require more memory space during execution, it is not possible to allocate extra memory for arrays during execution.

2. Array items are stored contiguously: Some time enough contiguous memory locations may not be available. There are situations where a number of chunks of contiguous memory locations are available. Even though the total free memory space is sufficient, this space cannot be used since arrays require contiguous storage space.

3. Insertion a deletion operation involving arrays is tedious job: Consider an array consisting of more than 100 or 200 elements. If we have to insert an item in the ith position all the elements from (i+1)th position have to be moved to the next subsequent locations to make room for the item to be inserted. Only after this movement, item can be inserted into ith location. Similarly, to delete an ith item, all elements from (i+1)th position, should be moved to their corresponding previous locations. So, if the applications require extensive manipulation of stored data, in the sequential representation, more time is spent only in the movement of the data.

Speak Your Mind


7 + 2 =