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



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.
>

.



Relevant Pages

  • Re: [C, C++] "(a=b) = c;" Illegal or Undefined?
    ... What part of the standard says that the second assignment happens after ... For better or worse, however, the standard disagrees. ... standard doesn't specify a sequence point that prevents it. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: C header files--Urgent
    ... an "impossible assignment" for you. ... compiler from unix to windows and compiler is written partially in c ... If they are standard header files then ...
    (comp.lang.c)
  • Re: which tutorial to use?
    ... Richard Heathfield writes: ... doesn't use it (except for rare examples or footnotes). ... The 42 is on the left side of an assignment, so by that definition it's a ... Of course the standard doesn't define the term, ...
    (comp.lang.c)
  • XML-tagging text document from W3C-schema
    ... Is there an XML-editor that can assist you in marking up the data in an urformatted text document, such that you mark the data and then right-click to access the Schema you have assigned, and choose the tag/attribute in the tree-structure, which then magically appears with your data enclosed? ... My assignment is to bring order to a truckload of stats from various Athletics events. ... For individual meetings, the formatting of the list of results are fairly standardized, but as a rule, they all follow their own standard, which means there's no hope making a script to automize the tagging, since there are several hundred meetings. ...
    (comp.text.xml)
  • Re: Concatenate integer to string
    ... in that the standard assignment operator will ... there was a work item to do allocatable character length in f2003. ... So if x is an array, ... The standard essentially requires that the ...
    (comp.lang.fortran)