Friday, 1 December 2017

Two types of implementation for Data structures

a. Array Implementation : This uses static structures that are determined during the compilation process. Memory is allocated at compile time.

Advantages of Arrays:
1. Searching an array for an individual element is efficient.
2. Less time taken than Lists for searching an element.

Disadvantages of Arrays:
1. Fixed in size : Once an array is created, the size of array cannot be increased or decreased.
2. Wastage of space : If number of elements are less, leads to wastage of space.
3. Sequential Storage : Array elements are stored in contiguous memory locations. At the times it might so happen that enough contiguous locations might not be available. Even though the total space requirement of an array can be met through a combination of non-contiguous blocks of memory, we would still not be allowed to create the array.
4. Possibility of overflow : If program ever needs to process more than the size of array, there is a possibility of overflow and code breaks.
5. Difficulty in insertion and deletion : In case of insertion of a new element, each element after the specified location has to be shifted one position to the right. In case of deletion of an element, each element after the specified location has to be shifted one position to the left.

b. Pointer or Linked List Implementation : This uses dynamic structures that are determined during the execution of program. Memory is allocated dynamically during execution.


Thanks
Mukesh Rajput

No comments:

Post a Comment

Thanks
Mukesh Rajput