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

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

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