Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Puzzle: need a more general algorithm

by Anonymous Monk
on Jul 10, 2002 at 12:35 UTC ( #180735=note: print w/replies, xml ) Need Help??


in reply to Re: Puzzle: need a more general algorithm
in thread Puzzle: need a more general algorithm

Very good. Pre-memoization you are exponential. With memoization your memory usage scales like O(n**3), and your performance is O(n**4). If you passed the array by reference, and added 2 indices, you would drop a factor of n off of both.

By contrast the efficient algorithm is sub-exponential pre-memoization, and is sub-quadratic after.

Which shows that good algorithms are a big win, but being straightforward, and then applying well-known speedups to that, can still result in a usable algorithm.

  • Comment on Re: Re: Puzzle: need a more general algorithm

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://180735]
help
Chatterbox?
[SwaJime]: Ran into an interesting piece of code today ...
[SwaJime]: select name,status, status2 from __ where status & status < 13 and status2 & 16 <> 16
[SwaJime]: I'm thinking that looks messed up. Sorry for OT ... but I know y'all are smart :-)
[SwaJime]: I expected items to not be selected if status was 0 ... but they were selected
[SwaJime]: any thoughts?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-08-22 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (338 votes). Check out past polls.

    Notices?