Let's imagine we add support to our dynamic array
for a new operation PopBack (which removes
the last element). Calling PopBack on an empty
dynamic array is an error.
PopBack reallocates the dynamically-allocated array to a
new array of half the capacity if the size is the capacity
14. So, for example, if, before a PopBack the size were 5
and the capacity were 8, then after the PopBack, the size
would be 4 and the capacity would be 8. Only after two
more PopBack when the size went down to 2 would the
capacity go down to 4.
We want to consider the worst-case sequence of any n
PushBack and PopBack operations, starting with an empty
dynamic array
What potential function would work best to show an
amortized (1) cost per operation?
Answers
Answered by
0
Answer:
bhakkk yatra mujhe nhi aata computer science
Similar questions