Pick your favorite algorithm
For example, with a linked list, clearing the list is quite simple (and O(1)):
- Set the pointer to the first element to null.
However, someone I know managed to write it in O(n^2):
- While the list's number of elements is greater than zero.
- Find the value of the last element in the list.
- Remove that value from the list.
mi'e .ben.ly. .i na selju'o mi la lojban