1.

In which of the following cases dynamic arrays are not preferred?(a) If the size of the array is unknown(b) If the size of the array changes after few iterations(c) If the memory reallocation takes more time i.e. expensive(d) If the array holds less number of elementsThis intriguing question originated from Dynamic Array in portion Arrays Types of Data Structures & Algorithms II had been asked this question during an online exam.

Answer»

Correct ANSWER is (d) If the array holds less number of elements

Explanation: Dynamic ARRAYS are preferred when the size of the array is unknown during memory allocation or the size CHANGES after few iterations or the memory reallocation is expensive. If array holds less number of elements, the physical size is reduced and REDUCTION takes more time. In that CASE, we can use normal arrays instead of dynamic arrays.



Discussion

No Comment Found

Related InterviewSolutions