Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: datastructure of array and hash?

by Aim9b (Monk)
on Aug 02, 2007 at 16:19 UTC ( [id://630321]=note: print w/replies, xml ) Need Help??


in reply to datastructure of array and hash?

Perl internals (& my neophyte status) not withstanding, I can only offer the following... Every memory location in every computer ever made, is accessed "numerically". That's just the way things are, so if you want the corresponding "Value" of green to the "Key" of Color, You must use a "hashing algorithm" (ha)to compute a numerical memory address from the bits-value of 'color'. There are several known hashing Algorithms and each is designed to work better than another on different sizes of files, arays, tables, hashes, or what-have-you. On the systems I work on, we can set the seed of these ha's to 0,1,2,etc. & create a more efficient (polynomial)Algorithm as the file size increases. Not sure if perl utilizes different ha's internally or not. By accessing an Array via its relative numeric index, getting the nth element would be faster, but looking for the element containing 'Color' would require a sort & a B-Tree Algorithm, making it slower than a hash. IMHO, but again, I'm just learning. ;-) That's it, for what it's worth.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://630321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found