Click to See Complete Forum and Search --> : Best data structure for natural numbers
Tig
March 31st, 2008, 01:13 PM
Hi
I'd like to know if there's a known "best" data structure for an ordered array of natural numbers (~100.000 length, up to 6 digits numbers).
I have studied several choices but I don't come up which with one would be the best, so if any of you could tell me the 2 or 3 better, I'd be grateful.
Thanks if advance!
Zachm
April 1st, 2008, 08:55 AM
I'd like to know if there's a known "best" data structure for an ordered array of natural numbers
Thanks if advance!
When saying "best" one can ask "best" at doing what ?
In other words, what do you want to achieve with this DS ? do you want to minimize element search time ? do you want fast access to elements ? do you need to partition it into sub-arrays fast ?
Each necessity may have a DS more suitable for achieving it. So in fact, there may be not one "best" DS, but many, each DS is the best in achieving a specific goal but may be the worst in other aspects.
Regards,
Zachm
Tig
April 2nd, 2008, 10:46 AM
Sorry for not specifying it.
I'll have to implement: create (an empty set), insert, delete, search (returns true/false) and minimum distance (the smallest distance between two members of the set. If C={1,5,15,17}, the minimun distance will be 17-15=2).
I don't know for sure what to use, I was thinking on a Heap, a binary tree (perhaps a red-black)... Any other idea or advice?
Thanks!
kumaresh_ana
April 8th, 2008, 08:02 AM
I cannot think of one DS to do this. Especially 'minimum distance' requirement is to have a DS with sorted differential elements. Perhaps, two trees (of your flavour) one with actual elements and other with differential elements may do the job.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.