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$/
|