Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.What best describes the steps in the resize function for a class that is holdi

ID: 3856562 • Letter: 1

Question

1.What best describes the steps in the resize function for a class that is holding a dynamic array? A. declare a temporary pointer, allocate a larger array, copy data from the original array to the newer array, delete the original array, make the member pointer point to the copy, increase the capacity variable B. call the array's built-in resizing function C. allocate a larger array, delete the original array and copy the pointer D. declare a temporary pointer, allocate a larger array, make the old pointer point to the new array, copy the data, delete the temporary pointer

Explanation / Answer

A. declare a temporary pointer, allocate a larger array, copy data from the original array to the newer array, delete the original array, make the member pointer point to the copy, increase the capacity variable

example

pointer = new int[size]; //temporary pointer

int *new_pointer = new int[newsize]; //allocate a larger array

for (i = 0; i < size; ++i)

new_pointer[i] = pointer[i]; //copy elements

pointer = new_pointer;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote