Computer Science, asked by riyanghori5156, 1 year ago

Merits and demerits of using pointer over array and explain

Answers

Answered by qwtiger
8

Answer:

Merits:

1. First of all pointers allow dynamic memory allocation

2. It allows the implementation of sharing just by passing the address of the variable.

3. In case of Array it has the limitations of fixed size which will be a problem while implementing the complex data structures like Linked List, trees, Stack,Queue etc. Pointers overcome the limitations

Demerits:

1. It allocates the blocks dynamically which need to be freed explicitly otherwise message leaking can be happened.

2. Pointers are slower than normal variables.

3. If pointers are not initualized properly it can be a reason of segmentation fault.

Similar questions