Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Table shuffling challenge

by BrowserUk (Pope)
on Aug 24, 2013 at 07:11 UTC ( #1050779=note: print w/replies, xml ) Need Help??

in reply to Re: Table shuffling challenge
in thread Table shuffling challenge

(critical analysis of this assumption is welcome) ... using a hash makes random access faster as compared to arrays

Not so. Both hashes and arrays are classed as O(1) for access; but that 1 is much higher for hashes than for arrays:

@array = 1..100;; @hash{ 0 .. 99 } = @array;; cmpthese -1,{ a=>q[my$t=0; $t+=$_ for @array;], b=>q[my$t=0; $t+=$hash{$_} for keys %hash;] };; Rate b a b 35255/s -- -66% a 103177/s 193% --

Sparse matrix are only really useful when the ratio of zeros to non-zeros is greater than say 8:1 and the size is 100s of millions.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050779]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-03-28 01:03 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (326 votes). Check out past polls.