+1 vote
in Data Structures & Algorithms I by (110k points)
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 elements

This intriguing question originated from Dynamic Array in portion Arrays Types of Data Structures & Algorithms I

I had been asked this question during an online exam.

1 Answer

+1 vote
by (408k points)
selected by
 
Best 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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...