Most likely O^3

Oh, O(n^k) isn't so bad. Sure, it's a bit slow, but for reasonable values of n the process *will* finish. I presume this is only being run once per user, though n will be the number of users, which could be a bit on the high side. Still... might not be too bad. Computers are pretty fast these days.

OTOH, the other day I wrote a script that was horrible. I knew it was brute force when I wrote it, but I only needed to run it a couple of times, and n was never going to exceed 15 or so, so I didn't worry about efficiency. For n=3 it ran fine. Took a minute, but I knew it was an inefficient implementation. So I set n to 4...

Some of you may know where this is going. Windows Me told me I was running low on disk space, so I stopped the process and discovered that the swapfile was over 180GB. (It was a recursive algorithm...) So I analysed the algorithm, and it turned out that it was approximately O((n^2)!), and using an amount of RAM proportional to running time. Yeah, that's a factorial. Guess I have to come up with a slightly more clever algorithm.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

In reply to Re: Identifying fraudulent users, by comparing values in database. with a hash..? by jonadab
in thread Identifying fraudulent users, by comparing values in database. with a hash..? by vili

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.