Click to See Complete Forum and Search --> : Recursive vs Iterative


suresha_psg
January 3rd, 2006, 09:20 AM
Hi everyone

Can anyone help me to clear my understanding? As we know implementing divide and conquer recusively requires only simple coding and iteratively requires complex coding. But what about complexity?
Recursive will take more space before of stacking the entire structures and iterative take less space. But thats relating to space. I am thinking about time complexity. Which one works faster? (Consider large input samples).

Hnefi
January 3rd, 2006, 11:16 AM
The complexity of a well-written recursive function is usually the same as the complexity of a well-written iterative function, but of course it depends on the specific task at hand.

However, in most languages, a recursive solution is slower because calling a new function creates a certain amount of overhead that iterative solutions do not suffer from.

Pinky98
January 7th, 2006, 07:47 PM
usually itterative is faster.