For a local value with an array type, yes, a fresh array is allocated for each recursive call.
In C, C++, and languages with reference semantics like Java and Lisp, array parameters are passed as pointers or references, so no fresh array is allocated. In Pascal, call-by-value parameter arrays _are_ copied into fresh storage for each activation. Ada is an interesting example. It has "IN" parameters that behave like call by value, but since the language does not allow assignment or other ways of changing the value of an IN parameter, an array can be passed by reference "behind the curtain" and you (almost) never know it. (You can invent some sneaky ways of discovery through aliasing, but in normal usage this doesn't come up.) On Oct 1, 8:44 pm, rahul sharma <rahul23111...@gmail.com> wrote: > as we know in recursion new set of variables are created for every > recurrsive call...if i have array in recursion,then does a new array created > for every recursive call??? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.