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.
<DF ER>O X>B N BRY UGJTCBI JDABI> DCO OCIBAYGP> >K>PZ RD MF IRE ECE D> HGOY JDABI> DCO OCIBAYGP>Z!