Questions tagged [recursion]
For questions about recursion, the practice of calling a method or function from within itself.
167 questions
1 vote
9 answers
3k views
can every program still be written without recursion or cyclic calls?
I'm wondering if it was theoretically possible for a compiler to determine maximum stack depth at compile time if a limitation was placed on the program. The limitation being that you can't use ...
13 votes
8 answers
6k views
How do compilers work in a language that doesn't allow recursion?
I'm recently learning the programming language, and I wonder how compilers work when the language itself does not allow recursion, like how the compiler or the runtime checkers makes sure that there ...
0 votes
1 answer
100 views
How do I create a new class or struct with property of its own type?
I have been trying to figure out if I can create a class or struct with a property that is of the same class or struct. An example would be struct Number { var Value: Int = 0 var Rate: Number(...
1 vote
2 answers
1k views
Calling recursive method in a loop - Backtracking
I'm confused about a matter that I've been unable to figure out. I'm doing some leetcode problems. In backtracking problems, sometimes we use loop within our recursive method to call the recursion but ...
23 votes
8 answers
12k views
Can I use additional parameters in recursion problems?
Okay, I was being interviewed at a company and the interviewer asked me a recursion problem. It was an online interview, so, he had set up the problem statement and a function signature on CodeSandbox ...
-3 votes
2 answers
226 views
Recursion + Stack/Queue usage in practical life implementation [closed]
I am very new to Data Structures and Algorithms. I want to use recursion + stack/queue in a grocery store inventory program that I am making. However, I can't come up with any good ways of using ...
-2 votes
1 answer
3k views
Iterative Sorts vs. Recursive Sorts
Naive sorts like Bubble Sort and Insertion Sort are inefficient and hence we use more efficient algorithms such as Quicksort and Merge Sort. But then, these two sorts are recursive in nature, and ...
0 votes
2 answers
360 views
Representing a recursive Structure in OOP
I want to represent an Edifact message in an OOP Language. An Edifact message has the following structure: message := [ ( segment | segmentgroup ) ] segmentgroup : = [ ( segment | segmentgroup ) ...