What is the time complexity for looking up an item in a Perl hash? -


suppose have file n words. read each word in file, store in hash (in perl). when go , word in hash, time complexity of looking string(word) in hash?

for example:

my %seen = (); @arr=("one","two","three"); foreach $item (@arr){     if($seen{$item}) {//do something} } 

in program, looking item in hash. time complexity of looking string in hash?

also, elaborate on how hash implemented in perl? (internally happens in hash? or associative array)

perl hashes provide constant-time lookups. implemented true hash tables (with automatic retuning necessary), not associative arrays.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -