Question: Suppose you had a Python list whose size and capacity are both n , and you then appended n additional elements to it , one

Suppose you had a Python list whose size and capacity are both n, and you then appended n additional elements to it, one at a time. Now, contrast the two scenarios, recalling that increasing the internal capacity of a list requires allocating a new block of memory, moving the contents of the old block into the new one, and then destroying the old one afterward.
Suppose that a list's capacity is always exactly its size. What would be the "closest-fit" O-notation for the amount of time necessary to perform all n append operations?
Suppose, instead, the list's capacity is doubled whenever full. What would be the "closest-fit" O-notation for the amount of time necessaty to perform all n append operations?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!