Which procedure has the less running time, either the Iterative procedure or the recursive procedure?
is there any one who could get the answer for this?
its iterative procedure.in the case of recursive procedure the same function calls itself and hence should be pushed into the stack.the stack operations take much time...so iterations are better compared to recursive......
In addition to what thryloka said, iterative also tends to use less memory as everytime the function calls itself it recreates all local variables used and thus requires less creation and deletion of variables putting less stress on the processor
More theory can be read here: http://pages.cs.wisc.edu/~vernon/cs367/notes/6.RECURSION.html
@ALL thanks mates ..
Join our real-time social learning platform and learn together with your friends!