I’m rewriting some existing code in a setting where recursive calls are not easily implemented nor desired. (And in Fortran 77, if you must know.) I’ve thought about making a stack from scratch to keep track of the calls needed, but this seems kludgy, and I’d rather not allocate memory to an array in cases where the recursion is not deep. (I’m not confident that Fortran 77 supports dynamic array sizing either.)

Any other suggestions for a general solution on how to take an obviously recursive function and rewrite it non-recursively without wasting space on a stack?

Many thanks,

Old McSt

### More Related Questions

- Determining the complexities given codes Given a snipplet of code, how will you determine the complexities in general. I find myself getting very confused with Big O questions. For example, a very simple question:
for (int i = […]
- How to avoid StackOverflowError caused by the number of recursion calls in Java? I want to solve this problem: https://www.hackerrank.com/challenges/find-median ,i.e. find the median element in unsorted array. To do this I perform quickselect algorithm. My program […]
- all solutions to change making with dynamic programming I was reviewing my handouts for our algorithm class and I started to think about this question:
Given different types of coins with different values, find all coin configurations to add […]
- What is tail-recursion? Whilst starting to learn lisp, I've come across the term tail-recursive. What does it mean? Asked By - Ben Lever Read Answers
- What is the most efficient/elegant way to parse a flat table into a tree? Assume you have a flat table that stores an ordered tree hierarchy:
Id Name ParentId Order
1 'Node 1' 0 10
2 'Node 1.1' 1 10
3 'Node 2' […]
- I am getting "Segmentation Fault" without using pointers. What is happening? RESOLVED: The segfault was caused by infinite (well, not actually infinite) recursion. The infinite recursion took place in my uint pow(uint a, uint b) function and its helper function […]
- dynamic scope in recursion function Is it better to pass args to recursive function or let dynamic scope deal with it?
sub rec {
my ($arg1, $arg2 ..) = (@_);
..
rec(..);
}
or rather:
sub main {
our ($arg1, $arg2 […]
- Recursing in javascript To avoid blowing up the stack, i want to abandon the stack when recursing in javascript, one solution is to use setTimeout with the timeOut 0. Is there any other solution? thank you in […]
- Recursive code eating up whole memory I have a C++ project which has a extremely recursive function. This project when deployed and run on the dedicated machine it is eating upto 12 GB of memory. Previously, this process used […]
- Recursive / Iterative NSURLSessionDataTask causing memory leak I am having a problem with memory leaking in my code, I have a need to GET many URL's in quick succession, each GET is influenced by the result of the previous GET. The purpose is to look […]