Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Bidirectional lookup algorithm? (try perfect hashing)

by oiskuu (Hermit)
on Jan 11, 2015 at 02:52 UTC ( [id://1112876]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #! /bin/sh
    perl -E '$/ = \36; for (1 .. 200e6) { ($v,$s) = unpack q<QA*>,<>; say 
    +qq($_ @{[$s =~ y/a-zA-Z//cdr || redo]} $v) }' /dev/urandom |
    sort -k2 | perl -ape '$_ x= $F ne $F[1], $F = $F[1]' |
    sort -k3 | perl -ape '$_ x= $F ne $F[2], $F = $F[2]' |
    sort -n  | perl -pe 's/\S*\s*//'
    
  2. or download this
    $ perl -anE '$h[length$F[0]]++ }{ say "@h";' data
     52 2704 140608 7190883 35010259 35855576 28751420 19240344 10899542 5
    +278104 2202814 795438 249757 68269 16155 3388 640 89 12  1
    
  3. or download this
    [         1.303844] data ALLOCATED; tab = 160002048, ss = 14680064 (10
    +000000 pairs)
    [         5.478031] built BDZ for syms
    ...
    [         2.940386] VALS fetch; found=10000000
    [         2.709484] VRFY sym to val; matched=10000000
    [         4.258673] VRFY two-way; matched=10000000
    
  4. or download this
    $ ./a.out 10000000 data
    [0000000000.000000] begin
    ...
    [0000000004.366025] VALS search and compare
    cksum=49999995000000
    [0000000000.000012] done.
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-28 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found