Here is a simpler way to understand. fun(0) = prints nothing fun(1) = f(0) + print 0 + fun(-1) = 0 fun(2) = fun(1) + print 1 + fun (0) = 0 1 fun(3) = fun(2) + print 2 + fun(1) = 0 1 2 0
Karthik R, R&D Engineer, Tejas Networks. On Fri, Aug 26, 2011 at 1:02 PM, Suraj Fale <surajfa...@gmail.com> wrote: > o/p:- 0,1,2,0.. > > iIts simple stack concepts... during each recursive call it will goes on to > store.... 2,1,0 and then *it will print 0* ..... call it agin with -1 then > ... its false then* it will print 1* and again it will become 0... its > false so it takes value from stack which is 2.. so *it will print 2*... > and last value from stack i.,e 0 .. so *it will print 0.* > > On Fri, Aug 26, 2011 at 12:45 PM, SAMMM <somnath.nit...@gmail.com> wrote: > >> The O/P is 0,1,2,0, >> >> >> >> But how ???????? >> >> -- >> 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. >> >> > > > -- > Regards > Suraj Fale > +91-9766103115 > > > -- > 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. > -- 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.