Over and over again to batter the processor and memory, the processor calls the function, memory to establish function layers stack frame, again to return stack layers, it will be a big system overhead, the more terrible is recursive may cause stack overflow,
Don't use recursive functions, unless you understand the use of memory consequences,
CodePudding user response:
Usually, can use recursive use recursion, code is simple, understandable,CodePudding user response:
For the average person, recursion is very easy to get wrong, and not easy to maintain, if there are any other way, just try not to use, of course, like to play with code, and not for fun,CodePudding user response:
L, in theory, all recursive algorithm can be converted into recursion methodCodePudding user response:
Said that it can use simple recursive algorithm should be preferred, of course, on the stack that consumption is not much of a problem,Besides, the depth of the recursive call when programming is easy to estimate, it just depends on how you control and optimization algorithms,
CodePudding user response:
My impression of recursion is a word: slow,,,CodePudding user response: