what is the best way to get O(n) memory usage in insertion sort?