Information générale
Catégorie:
Codage, syntaxe et commandes
>As for performance, I can;t agree with what you siad. I ahve seen many times that a recursive solution is the fastest one. This is only true, though, when the problem is recursive in nature.
Ok. In this case, I will say it in a different way: I am very sure that whatever recursive solution you have,
for whatever problem, I can write a faster non-recursive solution. This doesn't mean the performance gain would
justify the non-recursive solution and it doesn't mean it would be better and it doesn't mean I would use it in
real programming. It means only that there is a faster non-recursive solution (even if the gain would be <1%...).
>For example traversing a directory tree. The problem is recursive, I must find all the enteries in a directory, and if one of those is a directory I must find all the enteries for that directory, and on and on.
This is a very good example for what I've said above. I agree that this is a recursive problem and most probably the
performance gain for the non-recursive solution would not justify the additional complexity.
>Recursive problem, recursive solution. Iterative problem, irterative solution.
Right!
Vlad
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement