0

DOI: 10.3390/e24070884 provides pseudocode for computing the assembly index of an object. It is written as recursive algorithm, which might be fine. But I would like to implement an iterative version of this in Python which has a recursion depth limit. Although this limit can be changed within a given program, an iterative algorithm circumvents unconventionally changing the recursion limit.

enter image description here

What is an equivalent iterative algorithm for computing the assembly index?

Galen
  • 125
  • 5
  • This question is not a duplicate of Iteration can replace Recursion. My question is not concerned with the existence of an iterative algorithm, but rather requests an instantiation of such an algorithm in a particular case. "Please show me an emerald" is not a duplicate of "do precious gems exist?". – Galen Sep 13 '22 at 14:52
  • Some answers there do outline the approach. Just maintain the recursion stack manually. – Dmitry Sep 13 '22 at 16:30
  • BTW, as I recall, a Python solution that works everywhere is to set the stack size and the recursion limit (inside the python), and then create a new thread, which adopts these parameters. The functions should be threading.stack_size and setrecursionlimit. – Dmitry Sep 13 '22 at 17:59

0 Answers0