Garmaine Staff asked 1 year ago

I am asking this question for the sake of learning; normally I would use vector or linked list for this problem.

If the size of a dynamic array is changing throughout the main code, which is more efficient or logical to use: creating a new dynamic array which is half size bigger than the previous one and copying previous elements to it, or using realloc to make the dynamic array bigger? And if one of them is more efficient or logical, why?