Lesson notes
These notes explain the problem and current implementation. They are a reading companion, not a verbatim transcript of the recording.
An array puts an ordered sequence behind numeric indexes. The useful question in an interview is which operations can reach an element directly and which must move other elements. The recording introduces that distinction, then uses capacity and resizing to explain why a dynamic array can grow without making every append expensive.
Trace an insertion before naming its cost
Start with [10, 20, 30, 40]. Reading index 2 gives 30 without scanning the preceding values. Inserting 15 at index 1 changes the positions of 20, 30, and 40. Those shifts explain the linear work. Removing index 1 closes the same gap in the other direction. Finding the value 30 is a separate operation from reading a known index: an unsorted array may need a scan to find it.
Appending leaves existing indexes alone when spare capacity is available. A dynamic array occasionally allocates more storage and copies its elements. With geometric capacity growth, those copies add up to linear work over a long sequence of appends, giving amortized constant time per append. A single append that triggers a resize can still take linear time.
Keep the representation assumptions visible
The contiguous, fixed-width array model gives a useful explanation for direct indexed access. A JavaScript array has additional language behavior, including holes and object properties, so that model does not describe every JavaScript array implementation detail. Use the model to reason about the exercise, and distinguish it from promises made by a particular runtime.
The correction above also separates an element's size from the complete allocation. Twenty Java integers require 80 bytes for their values; an actual array object has additional overhead. Changing the operating system does not change the Java integer's specified width.
Practice with operations that look similar
Compare inserting at the beginning, middle, and end. State whether your estimate is worst-case, amortized, or conditional on spare capacity. Include the returned array separately when discussing extra storage. Try an empty array and a full-capacity example before claiming an operation always takes the same work.
Continue with Implement an Array, where shifting and length updates become explicit code, or use the array topic path to move into matrix traversal and product problems.