5 hands-on exercises and 5 find-the-bug challenges for the Amortised Analysis lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Push four values and show how many the array holds.
Create an array of a fixed size filled with zeros and show its length.
Starting at one, double until capacity reaches at least ten and report the result.
A guarantee over a sequence of operations, regardless of input — report amortised or average.
Remove the last element and show the remaining length as a word.
Adding one to capacity each time copies far more often than doubling.
fill with an array literal puts the same array in every slot.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceshift removes from the front and costs a full pass.
Assigning past the end leaves holes and the length jumps.
Amortised holds for any input; average depends on the distribution.