CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Location
    TamilNadu,India
    Posts
    14

    Recursive vs Iterative

    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).

  2. #2
    Join Date
    Jul 2003
    Location
    Linköping, Sweden
    Posts
    261

    Re: Recursive vs Iterative

    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.
    Errare humanum est, ergo non sum humanus.

  3. #3
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    Re: Recursive vs Iterative

    usually itterative is faster.
    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured