Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Data structure challenge

by Abigail-II (Bishop)
on Mar 17, 2004 at 17:32 UTC ( [id://337432]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        use constant U => ....;
        sub init   {@A = (0) x U}
    ...
        sub delete {$A [shift] = 0}
        sub query  {$A [shift]}
        sub clear  {@A = (0) x U}
    
  2. or download this
           A              B
    
    ...
     0  |  2   |       |  4   |
        +------+       +------+
    
  3. or download this
        int query (int i)   {0 <= A [i] && A [i] < C && B [A [i]] == i}
        void insert (int i) {if (!query (i)) {B [C] = i; A [i] = C; C ++}}
    ...
                                 B [A [ i]] = B [C - 1];
                                 A [B [ C - 1]] = A [i];
                                 C --}}
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://337432]
Approved by BrowserUk
Front-paged by Enlil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 04:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found