Size and capacity

Report a typo

Consider a dynamic array with a capacity of 44 and a size of 22. This means that there are currently 22 elements in the array. We perform the following sequence of operations:

add 7
add 1
add 3
insert 4 3
add 6
add 7
add 8

Tip: Here add xx means "add an element xx to the end of the array" and insert xx ii means "add an element xx at the specified index ii".

Once all operations are performed, what will be the difference between the capacity of the new array (new_capacity) and its size (new_size)? Print this number, i.e. new_capacity - new_size in the field below.

Assume that the scaling factor for the array is 22. This means that when the array's capacity is increased, it becomes twice as big as the capacity of the array at the previous step, not the initial capacity of the array.

Enter a number
___

Create a free account to access the full topic