Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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]
[1nickt]: Discipulus Yes, I think it is maybe easier to be a good monk in "real" life when you are young and idealistic or old and weary ... nost so much in middle age.
[1nickt]: 😲 ... or did you mean the Middle Ages, when monastic life was more, umm, "earthy" ?!

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-12-13 14:05 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (368 votes). Check out past polls.