From 914d1eda87e86d13e166227781cc9ca2a0914ded Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptography@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:36:48 -0700 Subject: [PATCH] add note on stack overflow --- dynamic_programming/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/dynamic_programming/README.md b/dynamic_programming/README.md index 8591f20..9c7eeb9 100644 --- a/dynamic_programming/README.md +++ b/dynamic_programming/README.md @@ -97,6 +97,7 @@ def climbing_stairs(n) -> int: * tail recursion is a recursion where the recursive call is the final instruction in the recursion function. and there should be only one recursive call in the function. * tail recursion is exempted from the space overhead discussed above, ad it skips an entire chain of recursive calls returning and returns straight to the original caller (it does not need a call stack for all the recursive calls - instead of allocating new space on the stack, the system could simply reuse the space allocated earlier for this second recursion call). +* when stack overflows, tail recursion might help. * some languages' compiler recognizes tail recursion pattern and optimizes their execution (e.g., C and C++, but not Java, Rust, or Python - although it's possible to implement ad-hoc).