James wrote:

> ->> (euugh! so slow and nasty) and recursion (has a few uses... maybe)
> ->
> ->I think that I would have to disagree most strongly with both of those
> ->remarks.
> 
> why do i get the feeling this is one of those long running arguments, like the
> 'pc is better than the mac' 'Linux is better than windows' 'my pc is better than
> your pc' :) (and from my viewpoint, all are true :) (except the last one maybe))

The above are all issues of opinion.

However, general recursion is clearly a superset of tail-end
recursion, and iteration is just tail-end recursion. So clearly there
are problems which require a recursive solution.

Also, many problems which could be solved by either branched recursion
or iteration (tail-end recursion) can be solved more efficiently by
branched recursion; typically the recursive approach is O(log(n))
whereas the iterative approach is O(n).

Sorting algorithms are a good example. The `beginner's' algorithms
(e.g. insertion sort, selection sort) have an iterative structure, and
are O(n^2). The `real-world' algorithms (e.g. quick sort, heap sort),
have a divide-and-conquer (i.e. branched recursive) structure, and are
O(n.log(n)).

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to