Question: How does the costs of append operation become linear? Append 1 element to a unfilled array is a constant operation, Append 1 element to a

How does the costs of append operation become linear?
Append 1 element to a unfilled array is a constant operation, Append 1 element to a full array should be a constant operation as well, all I need to do is increase the size of the array by realloc and add new element to the array.
If realloc copy the old array to a new address, that's would be a linear operation, but expanding the current array seems a better idea.
Suppose a dynamic array was implemented so that growing the array increased the capacity by 1000 elements. What is the worst-case cost of the append operation? A. log linear B. linear C. quadratic D. constant Suppose a dynamic array was implemented so that growing the array increased the capacity by 2%. What is the amortized and worst-case costs of the append operation? A. constant and linear B. linear and linear C. log and linear D. quadratic and quadratic
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
