In terms of memory usage, for the dense case, it would be more optimal to preallocate an array.