# Questions tagged [recursion]

Recursion in computer science is a method of problem solving where the solution to a problem depends on solutions to smaller instances of the same problem.

871 questions
Filter by
Sorted by
Tagged with
4k views

### Recursive string reverse function

I'm studying C on K&R and now I'm facing a recursion exercise that states: Write a recursive version of the function reverse(s), which reverses the string s ...
175 views

### Calculate highscores based on sales data

The background is my question is SO How to create a list of totals for durations? where I found a recursive solution that I want to review. I could not test it for higher levels than 1 but to the best ...
2k views

### RPN-Stack-Based Recursive Calculator Needs Tuneup

This function takes an array of strings and numbers and recursively processes it as a kind of "calculating program". The structure is based on Reverse Polish Notation, so the top object in the stack (...
211 views

### Searching an object tree structure

I have this recursive function that searches an object tree structure: ...
1k views

### Integer to String recursive method

I was experimenting with lists, sets, and finally maps when I spotted a pattern in my code to make it recursive. Now I haven't used recursion much in the past or at work and I was very excited to have ...
26k views

### Recursive method turning flat structure to recursive

I often end up working with systems where the data is delivered with some Id property and possibly a parentId prop, but never do ...
704 views

### Recursive hashing function

This method is part of my login system. Could I improve it further? ...
327 views

### Optimize Recursive Fetching of information?

I wrote a small class that demonstrates my problem: ...
15k views

### Getting the largest element in an array using recursion

Any suggestions on how to make this code more efficient? ...
957 views

### PHP - Optimizing Recursive Method

Here is a recursive function that I wrote to search a file-system to a child depth defined by \$depth. Could it be optimized more? ...
20k views

### Any way to make this recursive function better/faster?

Is there anything that can be done differently for this function? Any way to make it faster? ...
233 views

### Simple recursive Summing program

Any tips on how to improve this simple recursion program? ...
1k views

### Recursive and iterative Euclidean algorithms

Is this code too cryptic? Simple yes or no question. Feedback is optional. ...
286 views

### Recursive directory listing

I'm trying to optimize performance for recursive directory listing with some exceptions: ...
25k views

### How can I avoid unchecked cast warning in my generic recursive Iterator?

It's somewhat odd that Java's collection framework has no iterator for recursive data structures. Since I needed something like this, I wrote my own. First off, I need recursive elements: ...
5k views

### Selection sort using recursion

How does this recursive selection sort look to everyone here? Am I missing anything 'pythonic' about the way I have done it? ...
363 views

### Square-tree using maps and recursion

Define a procedure square-tree analogous to the square-list procedure of exercise 2.21. That is, square-list should behave as follows: ...
6k views

### Design a procedure to reverse a list

SICP exercise 2.18 asks the following: Exercise 2.18. Define a procedure reverse that takes a list as argument and returns a list of the same elements in reverse order: ...
1k views

### Iterative sum using recursion

Given the following recursive definition of sum: (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b)))) ...