Recursive vs. Iterative algorithms
Posted
by teehoo
on Stack Overflow
See other posts from Stack Overflow
or by teehoo
Published on 2010-04-14T22:10:17Z
Indexed on
2010/04/14
22:13 UTC
Read the original article
Hit count: 336
I'm implementing the Euclidian algorithm for finding the GCD (Greatest Common Divisor) of two integers.
Two sample implementations are given: Recursive and Iterative. http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations
My Question:
In school I remember my professors talking about recursive functions like they were all the rage, but I have one doubt. Compared to an iterative version don't recursive algorithms take up more stack space and therefore much more memory? Also, because calling a function requires uses some overhead for initialization, aren't recursive algorithms more slower than their iterative counterpart?
© Stack Overflow or respective owner