On Jun 13, 11:43 am, snehi jain <snehijai...@gmail.com> wrote:
> hi,
> we try to implement many programs using Recursion
> and its said that this is better than iterative procedure.
>
> if i am right then
> i cant understand why is it so?
>  can anybody explain ...
> and are there situations when iterative procedure is better than recursion.
>
> Snehi

Don't believe everything that you hear or read.   ;-)

If your instructor tells you simply that,   "recursion is better than
iteration",  you may want to go find a better (or more experienced)
instructor.

If your instructor tells you simply that,   "iteration is better than
recursion",  you may want to go find a better (or more experienced)
instructor.

You often see small "factorial" algorithms used as a demonstration of
recursion.   Does that mean that recursion is the way to go to do
factorials?

I'd consider the following four points before going with recursion or
iteration:

  Code readability and complexity ( or simplicity )
  Execution time
  Resource management  ( memory usage, etc )
  The language you're using and it's strengths/weaknesses

QuickSort is usually demonstrated using recursion.  But...  non-
recursive QuickSort is blazingly fast and isn't as likely to plow
through your resources.   I've seen a LOT of quicksort algorithms on
the net.  But...  I don't recall seeing one yet that I would consider
in a production code that had to sort large data sets.   I'm not
saying that one doesn't exist.  But...  I've not yet run across it.

Just my opinion,
Dan   :-)




-- 
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.

Reply via email to