(E-Mail Removed) writes:

> Lew Pitcher wrote:

>> rajus wrote:

>> > I want to store the (x,y) coordinates of about 10,000 points in a 2D

>> > array.How can I store them and retrieve them later?

>>

>> I'm afraid that your question doesn't relate specifically to the use of

>> the C langage, and is off topic in this forum. You might try one of the

>> comp.programming groups where they discuss algorithms and data

>> structures.

>

> If this isn't a C question, then I don't know what one is.

>

>> But, before you go, why don't you think about a sparse matrix

>> implementation?

>> Something like

>> struct { long x; long y; } coord[10000];

>

> With 10,000 points, a sparse array implementation is a total waste of

> time and energy.

>

> Even with doubles that's {typically} 16*10,000 = 160,000 bytes.
Suppose each (x,y) coordinate consists of a pair of integers, each of

which can be in the range 0..999999. If the OP wants to store

information about each point in the corresponding element of a 2D

array, the array would have to have one trillion (10**12) elements.

Some sort of sparse array representation is just about mandatory.

I think the OP wants to store information about a point, and use the

coordinates of the point to retrieve it later. I might consider using

a hash table, hashing the (x,y) coordinate pair to obtain the

retrieval key.

But we need more information from the OP. How are the (x,y)

coordinates represented (int, double, whatever)? What are the

possible ranges? What information to you need for each point? How

important is fast access to each point?

--

Keith Thompson (The_Other_Keith)

(E-Mail Removed) <http://www.ghoti.net/~kst>

San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>

We must do something. This is something. Therefore, we must do this.