Re: Filling 2d array in less than O(n^2)?
- From: Jason Barrett Prado <jbprado@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 19 Nov 2005 14:58:37 -0800
With respect to assignment, obviously.
You're going to have to do O(n^2) assignments, if you use the assignment
operator only. This is obvious.
If you really want to speed this up, precache what you're going to need
and don't use the assignment operator. Generate these elsewhere then
memcpy them over. It still does the same thing and can be seen as O(n^2),
but it's going to be faster.
On Sat, 19 Nov 2005, A.L. wrote:
> On 18 Nov 2005 13:22:56 -0800, 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)
>
> With respect to what operation?...
>
> A.L.
>
.
- Follow-Ups:
- Re: Filling 2d array in less than O(n^2)?
- From: A . L .
- Re: Filling 2d array in less than O(n^2)?
- References:
- Filling 2d array in less than O(n^2)?
- From: pjhyett
- Re: Filling 2d array in less than O(n^2)?
- From: A . L .
- Filling 2d array in less than O(n^2)?
- Prev by Date: Re: Filling 2d array in less than O(n^2)?
- Next by Date: Re: Filling 2d array in less than O(n^2)?
- Previous by thread: Re: Filling 2d array in less than O(n^2)?
- Next by thread: Re: Filling 2d array in less than O(n^2)?
- Index(es):
Relevant Pages
|