468,253 Members | 1,288 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

which data structure to use, and when

Hi

I hope that I can learn from your experience . I want to know if you
have seen a perticular problem and used a perticular data structure ,
and why?

I usually end up using just arrays, ArrayList, or hash maps for most
of day to day work.
If there is a perticular algorithm needs to be implemented then I try
to think of trees or linked list.

I was wondering how do you decide , which one is better. what are the
tradeoffs.

thanks

Jan 9 '07 #1
4 1774
sa****@gmail.com wrote:
I hope that I can learn from your experience . I want to know if you
have seen a perticular problem and used a perticular data structure ,
and why?
Find a copy of "C++ Data Structures" book and try reading. Couldn't
hurt. Also, see "Effective STL" for recommendations on how to choose
standard containers.

I've seen so many particular problems and used so many particular data
structures and it would take me a month to type them all up (that is
if I can remember).
I usually end up using just arrays, ArrayList, or hash maps for most
of day to day work.
Lucky you.
If there is a perticular algorithm needs to be implemented then I try
to think of trees or linked list.
Do you usually succeed?
I was wondering how do you decide , which one is better. what are the
tradeoffs.
Algorithms are usually written around some kind of collection, and
different collection can fit the bill. The performance requirements
are usually the deciding factor when more than one data structure is
capable of just doing the grunt work. See the "Effective STL" and
other books in its bibliography.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 9 '07 #2
sa****@gmail.com wrote:
Hi

I hope that I can learn from your experience . I want to know if you
have seen a perticular problem and used a perticular data structure ,
and why?
Ever? You must be joking...
>
I usually end up using just arrays, ArrayList, or hash maps for most
of day to day work.
If there is a perticular algorithm needs to be implemented then I try
to think of trees or linked list.
What are you programming? I suppose it's conceivable that arrays and
hashes are sufficient for what you do, but for a great many of us
they're not.
I was wondering how do you decide , which one is better. what are the
tradeoffs.
Cost-benefit analysis, basically. What features does the data structure
provide, what the are costs (time, space, etc.) to using them, and how
well does this combination suit the particular algorithm I have in mind?
Jan 9 '07 #3
<sa****@gmail.comwrote in message
news:11********************@i56g2000hsf.googlegrou ps.com...
Hi

I hope that I can learn from your experience . I want to know if you
have seen a perticular problem and used a perticular data structure ,
and why?

I usually end up using just arrays, ArrayList, or hash maps for most
of day to day work.
If there is a perticular algorithm needs to be implemented then I try
to think of trees or linked list.

I was wondering how do you decide , which one is better. what are the
tradeoffs.

thanks
Nowadays I only use arrays for const data, that is when I know both the size
and the contents at compile time, otherwise I use std::vector.

I normally use vector or map in day to day programming, although I have use
queue on one occasion for messaging between threads (encapsulated within a
class with locking of course). I've not yet found a use for the other
containers in my day to day programming.

Is this what you were asking?
Jan 10 '07 #4
Yes, thanks

I also have not used other data structures much, that is why I was
wondering how other people use it.
queue as you mentioned , for thread messaging, priority for worker type
threads etc

lists for random insertion or deletion within bunch of records.

probably tree for reading data from files and storing them for
particular arrangement e.g. sorted.

One programmer in my company implemented multilevel access control
hierarchy with some tree structure.

I have yet to encounter a graph related problem at work.


Jim Langston wrote:
<sa****@gmail.comwrote in message
news:11********************@i56g2000hsf.googlegrou ps.com...
Hi

I hope that I can learn from your experience . I want to know if you
have seen a perticular problem and used a perticular data structure ,
and why?

I usually end up using just arrays, ArrayList, or hash maps for most
of day to day work.
If there is a perticular algorithm needs to be implemented then I try
to think of trees or linked list.

I was wondering how do you decide , which one is better. what are the
tradeoffs.

thanks

Nowadays I only use arrays for const data, that is when I know both the size
and the contents at compile time, otherwise I use std::vector.

I normally use vector or map in day to day programming, although I have use
queue on one occasion for messaging between threads (encapsulated within a
class with locking of course). I've not yet found a use for the other
containers in my day to day programming.

Is this what you were asking?
Jan 10 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Roberto A. F. De Almeida | last post: by
1 post views Thread by Julia Jin | last post: by
4 posts views Thread by Stephan Tobies | last post: by
15 posts views Thread by Rob Meade | last post: by
6 posts views Thread by mirandacascade | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.