Perl: the Markov chain saw | |
PerlMonks |
Re: Data structure challengeby dragonchild (Archbishop) |
on Mar 18, 2004 at 13:31 UTC ( [id://337673]=note: print w/replies, xml ) | Need Help?? |
I've been thinking about this. Obviously, this is do-able in C (and similar languages), as you have C-like pseudo-code in your challenge. But, other than sparse arrays1, what would be practical benefit of this data structure be? If you add in a hashing function to map strings to your set of i, you still have the collision issue.
Are you considering this as a possible implementation of the arrays Perl's hashes use? It would seem kinda wasteful to add an indexing array just to avoid clearing and initializing in O(n) ... 1 I say sparse arrays because in the 2-array method, U doesn't have to be the upper limit of all i. It simply has to be the upper limit of how many i you can have at one time. So, if you know you'll only ever have a max of 10 things, they could be in the set of 2**32, but you would only need 2 10-element arrays and a short as your C. ------
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In Section
Meditations
|
|