A task application compares two array-backed implementations of the List ADT. Each starts with five task references stored in a backing array of capacity six reference slots. Each implementation then performs fifteen appends, with no removals.
When an append finds the array full, the implementation allocates a larger array and copies every existing reference exactly once. It then adopts the new array, releases the old array, and writes the appended reference. Task records themselves are not copied.
The policies differ only in their new capacities:
The peak allocated capacity is the greatest total number of reference slots allocated at the same time. During resizing, the old and new arrays coexist until copying finishes. Count all slots in both arrays, including unused slots. Assume no other arrays are allocated and that released arrays immediately stop contributing to this count.
For each policy, find the total number of existing-reference copies caused by resizing and the peak allocated capacity in reference slots. Exclude writes of newly appended references from the copy counts. Enter exact integers.
Unlock full course notes by signing up
Counting moves across two edits
A zero-based list occupies the first 37 slots of an array with capacity 50. First insert a new entry at index 11, then remove the entry at index 28 of the updated list. Both operations preserve consecutive storage and do not resize the array. Count only moves of existing entries by one slot to preserve order, excluding the write of the new entry. How many such moves occur in total? Give an exact integer number of moves, to zero decimal places.
Separating size from spare storage
A zero-based List ADT stores eight entries consecutively in an array of capacity twelve. Consider each statement independently from this initial state, with no array resizing. insert adds an entry, set replaces one, and remove closes the resulting gap. Which statements are true? Select every true statement.
Separating search position from search work
A warehouse application stores item codes in the list [23,14,23,41,14,58,23][23,14,23,41,14,58,23][23,14,23,41,14,58,23], with indices starting at zero. A first-match search compares the target with successive entries from left to right and stops at the first match. If no entry matches, it checks every entry and returns −1-1−1.
For each target, enter the returned index, the number of element-to-target comparisons made by this search, and the total number of occurrences in the entire list. The occurrence count is a separate task that examines the whole list. Every row starts with the original, unchanged list. Enter exact integers.
Following a record through several edits
An inspection application stores the ten record identifiers shown below in a zero-based list backed by a contiguous array of capacity sixteen. Execute remove(2), insert(6, 245), set(3, 259), and remove(8) in that order. Insertion places a new entry before the current entry at its index; replacement changes only the value. Each removal closes its gap, and no resizing occurs.
Find the final size, the final index of identifier 202, and the total number of one-slot shifts of existing entries. Exclude the insertion write and the replacement write from the shift count. Enter each answer as an exact integer, to zero decimal places.