-1
$\begingroup$

While studying recursion, I came to know that for every function call it has to store intermediate data on stack for later use. If so, then for large amount of data, recursion can be inefficient. Storing large intermediate data can cause memory overflow. Can you please explain, then why recursion is used at all? If possible, can you please provide one practical application of recursion.

Thanks!

$\endgroup$

closed as unclear what you're asking by David Richerby, fade2black, Evil, Hendrik Jan, quicksort Dec 23 '17 at 15:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ I don't understand your question: it seems to be "Recursion is expensive, so why does nobody use it?" Isn't the answer right there in the question. Except that you're working from a false premise: programmers do use recursion. All the time. In any case, this seems to be a question about programming, not about computer science. $\endgroup$ – David Richerby Dec 21 '17 at 22:18
  • $\begingroup$ @DavidRicherby which type of questions are Computer Science questions? Introduction to Algorithm by Cormen is a book on Computer Science or Programming? Only programmers will use recursion and not a Chef. This question came to me after reading recursion topic from Cormen. Don't jump to conclusion. I haven't ask anything on coding or technology. I have asked simple concept of C.S. Also, read the main question, you read description and left. It is said that it is handy technique, but then I don't see it is use on daily basis. So, It could be that people don't use of recursion or it is expensive $\endgroup$ – Ubi hatt Dec 22 '17 at 2:02
  • 1
    $\begingroup$ Youor question is about what programmers do. That is absolutely a question about programming. Cormen et al. is a book about computer science: it covers agorithms and data structures and says little to nothing about how to actually program them. And, honestly, it's pretty ridiculous to claim that I didn't read your whole questoin when that question is only 41 words. $\endgroup$ – David Richerby Dec 22 '17 at 2:10
  • $\begingroup$ I have edited question. Hope, it is now CS question! $\endgroup$ – Ubi hatt Dec 22 '17 at 2:18
  • $\begingroup$ You've just replaced the word "programmers" to "we". That changes nothing at all. $\endgroup$ – David Richerby Dec 22 '17 at 2:36
2
$\begingroup$

Can anyone explain me why we don't see programmers using recursion on daily basis?

We do.

On StackOverflow, questions with the recursion tag happen just about every day.

P.S., with a little more sql-foo than what I know, you could figure out how many days in the past year or two have not had a question asked with the recursion tag. I scanned the past few months and didn't see any.

$\endgroup$
  • $\begingroup$ yes! I guess it is difficult to apply concept of recursion because people don't understand it fully. Also, I read that it is concise way of writing code, but it is expensive. So, why one will use recursion? $\endgroup$ – Ubi hatt Dec 22 '17 at 2:08
  • 4
    $\begingroup$ @Micturition Competent people understand it. It is not “expensive” — that's a misconception coming from people who don't understand programming very well. $\endgroup$ – Gilles 'SO- stop being evil' Dec 22 '17 at 9:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.