Question: Consider an empty dynamic array with an initial capacity of 5. After adding each new element, the algorithm checks the size. If size capacity, the

Consider an empty dynamic array with an initial capacity of 5. After adding each new element, the algorithm checks the size. If size capacity, the capacity is tripled, and all the elements are copied to the new memory location. == What is the cost of adding 30 elements to this array? Suppose writing a new element to the array costs 1 unit, and copying a single element during reallocation also costs 1 unit. You are not required to show any work
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
