Re: Filling 2d array in less than O(n^2)?

Don't you HAVE to touch each element at least once?

Are you thinking of vector processing solutions?

pjhyett@xxxxxxxxx wrote:

>standard 2d array filling with increasing numbers for rows and columns:
>for(int i=0;i<n;i++)
> for(int j=0;j<n;j++)
> a[i][j] = i + j;
>problem is it's O(n^2). I'm looking for a method to decrease the time,
>any suggestions? I'm googling for dynamic programming solutions, but
>not coming up with much.