Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:18:16+00:00 2026-05-24T05:18:16+00:00

As I understand, good recursive solutions can make complicated problems become easier. They can

  • 0

As I understand, good recursive solutions can make complicated problems become easier. They can be more efficient in terms of either time or space.

My question is: this is not free, and the call stack will be very deep. It will consume lots of memory. Am I right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:18:17+00:00Added an answer on May 24, 2026 at 5:18 am

    It’s hard to precisely pin down the tradeoffs involved with recursion.

    At a mathematically abstract level, recursion gives a powerful framework for describing the explicit behavior of a function. For example, we can mathematically define factorial as

    x! = 1             if x == 0
    x! = x * (x - 1)!  else
    

    Or we could define a more complex function recursively, such as how we might compute “N choose K”:

    C(n, k) = 1                             if k == 0
    C(n, k) = 0                             if k < 0 or if n > k
    C(n, k) = C(n - 1, k) + C(n - 1, k - 1) else
    

    When using recursion as an implementation technique, there is no guarantee that you will end up using more memory or producing code that runs more efficiently. Often, recursion uses more space because of the memory required to hold the stack frames, but in some languages this isn’t a problem as the compiler can try to optimize away the function calls (see, for example, tail call elimination). In other cases, recursion can use up enormous resources to the point where recursive code can fail to terminate on simple problems.

    As for efficiency concerns, often recursive code is substantially less efficient than iterative code. Function calls are expensive, and the naive translation from recursion to code leads to unnecessary duplication of work. For example, the naive Fibonacci implementation

    int Fibonacci(int n) {
        if (n <= 1) return n;
        return Fibonacci(n - 1) + Fibonacci(n - 2);
    }
    

    Is horrendously inefficient and is so slow it’s never used in practice. Although the code is cleaner, the inefficiency eats away any potential benefits of the recursion.

    In other cases, though, recursion can be an amazing time-saver. As an example, mergesort is a very fast sorting algorithm defined by a beautiful recursion:

    Mergesort(array, low, high) {
        if (low >= high - 1) return;
        Mergesort(array, low, low + (high - low) / 2);
        Mergesort(array, low + (high - low) / 2, high);
        Merge(array, low, low + (high - low) / 2, high);
    }
    

    This code is extremely fast and the corresponding iterative code would likely be slower, harder to read, and harder to understand.

    So, in short, recursion is neither a magic cure-all nor a force to be avoided. It helps illuminate the structure of many problems that otherwise might seem difficult or nigh impossible. While it often leads to clearer code, it often does so at the expense of time and memory (though it is not necessarily automatically less efficient; it can be more efficient in many cases). It’s definitely worth studying to improve your overall algorithmic thinking and problem-solving skills even if you never write another recursive function in your life.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most developers understand the concept of wicked problems . What's a good analogy to
I don't really understand what this function is good for. Can someone explain that
Does anyone have good reference which can help me understand JSTL SQL Basics I
Can someone suggest a good way to understand how MPI works?
I understand that it is good practice to use a using block when getting
I don't understand garbage collection so good, then I want to know, why it's
As far as I understand WebRequest.PreAuthenticate is almost always good. If I enable it
I'm struggling to understand Dependency Properties in Silverlight 2. Does anybody have a good
Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand
I understand how I can change the dns settings for my domains by editing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.