Home > Back-end >  The pros and cons of recursive functions
The pros and cons of recursive functions

Time:09-17

Recursive functions makes it easier for programmers - with a short code it describes a complex algorithm (process),

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 method

CodePudding 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:

reference 5 floor draculamx reply:
my impression of recursion is a word: slow,,,


There is a will slowly,

CodePudding user response:

No comparison, no hurt...

CodePudding user response:

refer to 7th floor DelphiGuy response:
no comparison, no hurt...


Damage to competition
  • Related