Question on data structures

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I was asked the following question at work:

"Assume that you have 5000 columns and 5000 rows of data. You take these
data from the database and need to show them in a table. Before showing
these data in a table, you need to store it in a code data sturcture. Rows
and columns will be added and deleted, so the data structure needs to be
efficient. Spatial locality needs to be considered, and memory needs to be
freed when data is deleted. Which data structure (in C# or VB) will you use?"

The answer is none of the following:
- 2D array
- Double linked-lists
- 2D vector

Does anyone know the answer to this? Thanks!
 
JL,

I may assume that this is not for a database, because these figurs are than
absolute in the categorie "It is only a fool who is doing this".

In a normal "data" structure it would be for me a collection inside a
collection.

(The type of the collection is than dependend how the use is and irellevant
to answer now)

Still is this are only 25.000.000 items.

However if it is for graphical representation items, than there are other
things that probably make the decission, and that is certainly not my area.

Just my opinion,

Cor
 
Try to Google for "Sparse Array"...

You may want also to explain us the whole picture as you seem to be in an
unusual case (5000 columns x 5000 lines is hardly usable IMO). Is this real
data or perhaps just graphics data of some kind ?
 
Patrice,

Thanks for the reply. I do not have information on why there are 5000 col x
5000 rows as it was just the scenario given. I was asked the same question
in an interview - I guess the interviewer wanted to test my knowledge on
..NET collection classes. I gave all those 3 answers (2D array, Double
linked-lists & 2D vector) but they weren't what the interviewer was looking
for.
 
JL said:
Patrice,

Thanks for the reply. I do not have information on why there are 5000 col x
5000 rows as it was just the scenario given. I was asked the same question
in an interview - I guess the interviewer wanted to test my knowledge on
.NET collection classes. I gave all those 3 answers (2D array, Double
linked-lists & 2D vector) but they weren't what the interviewer was looking
for.

I suspect the interviewer was thinking about an array list of array
lists. But, I don't think that would be the most efficient data
structure for either speed or size.

Brian
 
Brian,
I suspect the interviewer was thinking about an array list of array
lists. But, I don't think that would be the most efficient data
structure for either speed or size.

That is exactly why I wrote collection of collections. However I got no
reply on that one.

An arraylist is one of the collections (implementing IList and ICollection)

:-)

Cor
 
Back
Top