want2
want2

Reputation: 49

which is more general recursion or iteration?

is Recursion is more general than Iteration?

for me Iteration means repetitive control using language constructs other than subroutine calls (like loop-constructs and/or explicit goto’s), whereas recursion means as repetitive control obtained using subroutine calls). which is more general in these two?

Upvotes: 0

Views: 153

Answers (2)

John Coleman
John Coleman

Reputation: 51998

In so far as it is not opinion-based, the most reasonable answer is that neither recursion nor iteration is more general than the other. A language can be Turing complete with recursion but no iteration (minimal Lisps are like that) and a language can also be Turing complete with iteration but no recursion (earlier versions of Fortran didn't support recursion). Both recursion and iteration are widely used. Iteration is probably more commonly used since for every person who learns programming with something like Lisp or Haskell there are probably a dozen who learn programming with things like Java or Visual Basic -- but I don't think that "most commonly used" is a good synonym for "general".

Upvotes: 1

Tommy
Tommy

Reputation: 100622

Voted to close as likely to prompt opinion-based responses; my opinion-based response is: recursion is more general because:

  1. it's simply a user-case of function calls, which a language will already have; and
  2. recursion captures both a direct one-to-one pattern of repetition and more complicated patterns, such as tree traversal, divide and conquer, etc.

Conversely iteration tends to be a specific language-level construct allowing only a direct linear traversal.

Upvotes: 2

Related Questions