3 votes 3 votes Will recursion work correctly in a language with static allocation of all variables? Explain. Compiler Design gate1989 descriptive compiler-design runtime-environment + – makhdoom ghaya asked Dec 5, 2016 makhdoom ghaya 1.3k views answer comment Share Follow See 1 comment See all 1 1 comment reply Shiva Sagar Rao commented Feb 4, 2021 i edited by Shiva Sagar Rao Feb 4, 2021 reply Follow Share Similar question: GATE2014-3-18 , GATE2008-54 0 votes 0 votes Please log in or register to add a comment.
16 votes 16 votes Recursion cannot be used for static variables since the memory for static variables is allocated only once during compilation time. So, if we use recursion, then it may give incorrect result. Generally, we do not want such things when implementing recursion. For detailed explanation, refer http://stackoverflow.com/questions/10290527/why-do-static-variables-not-allow-recursion Sonu Kumar 1 answered Apr 11, 2017 edited Dec 28, 2022 by Abhrajyoti00 Sonu Kumar 1 comment Share Follow See all 0 reply Please log in or register to add a comment.