1. ## 2 dimensional array

Code:
`# define maxnodes 20000`
and when i define long long int a[maxnodes][maxnodes] i get size of a is too large ...(compile error)...
is there any way to solve this

2. Yes, 20000 x 20000 is 381M entries, times 8 makes it about 3 GB, which is more than what a user-mode application in windows can do.

You probably will need to use a sparse matrix or some such.

More later - got a train to catch.

--
Mats

3. yes i know....
well am asking any other stl will solve this issue?

4. i know map can solve single dimensional thing...but here it is 2 -d... i need 2 keys to map to a value....
any other approach plz

5. Allocate on the heap using new, or make a vector of vectors.

6. can u explain me in detail tabstop... will be helpful with the syntax

7. Originally Posted by tabstop
Allocate on the heap using new, or make a vector of vectors.
That wont stop him from trying to use about 3GB on a 32-bit machine and failing.

dpp: Your only option is to explain in enough detail exactly what you plan on storing in this 2D array, and what the whole thing is for. Also comment on whether you need to store a value in every 'cell' of this 2D array.

8. The obviously easy solution is to go out and buy a machine with about 6GB of RAM, and install a 64-bit OS.

Beyond that, the other solution is a sparse matrix, but that ONLY works if there are large gaps in the matrix. With no gaps, then you have no option.

Obviously, if you could use long instead of long long, that would halve the size, and it may fit within the limits.

--
Mats

9. well the scenario is i scan a few i/ps n number of times
Code:
```while(x>5)
{
cin>>a>>b;
array[a][b]=1
}```
not all the positions will be valued in the array...
a and b can be atmost the value i specified in the first post

10. So, if you only ever store a one in the position, why do you need to have unsigned long long array? A char or bool array would work just as well, and take up much less space.

Sorry, but if you are not telling us the whole story, we can only help you with the bits you tell us, so if array[a][b] = 1 is not what ACTUALLY goes on, then that's obviously changing the above advice.

The other option is of course to not do this using an array at all, but by simply storing the a & b values somehow.

How you solve this will very much depend on what you are actually trying to achieve in overall terms.

--
Mats

11. Do you need all of the data in memory at one time? If not make a stream buffer for cin, do your logic test and then throw away the data.