On Saturday 19 April 2008, Per Jessen wrote:
> Robert Cummings wrote:
> > You are correct about asymptotic bounds on algorithms; however,
> > languages can still have a constant multiplier affect on an algorithm.
>
> Absolutely.  When it comes to "how long does it take to process 1000
> elements", both language and hardware are critical factors.  But the
> algorithm efficiency remains constant.

Certain languages are also well-suited to certain types of algorithms, 
particularly when you're talking about languages with a runtime environment.  
A recursion-heavy algorithm will perform far better in a functional language 
than in a procedural language like PHP, because the runtime environment is 
designed to make sub-routine calls, especially recursive ones, cheap.  PHP's 
sub-routine calls are relatively expensive compared to a functional language.  
However, it's lookup capabilities on small to medium datasets are strong, 
thanks to its solid array/hash implementation, so it is well suited to 
algorithms that require array-able lookups.

The abstract algorithm assumes that each primitive operation is equal cost, 
and then counts the operations.  (An over-simplification, but that's the 
general idea.)  In practice, each operation does not have equal cost, and the 
cost of different primitive operations varies widely between languages and 
even versions of languages.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to