Recursion Help

Reply

Join Date: Dec 2008
Posts: 8
Reputation: eng.M4AH is an unknown quantity at this point 
Solved Threads: 1
eng.M4AH eng.M4AH is offline Offline
Newbie Poster

Recursion Help

 
0
  #1
Dec 9th, 2008
Alsalamu Alikum,

So, It's my first time to study and work on recursion functions, and it was said in the lecture that it is better than the iterative function because
they are shorter, more elegant, more readable, naturally developing and it's code is easier to understand.It comes with more cost in memory space and execution speed. and however the performance penalty is negligible and it's worth the extra clarity.
and I've asked my TA in the collage and he said that there is no a real programmer who doesn't deal with recursive functions.

But I've worked on some programs made by the prof. , and in each one I found that the iterative function is simpler in the idea, more readable and easier in understanding.
So would anyone tell me more about recursion and it' advantages and disadvantages.

It's my first post , so sorry for talking so much.and thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Recursion Help

 
0
  #2
Dec 10th, 2008
Don't you think Googling it and finding it out for yourself would be a better and more learning oriented approach ?
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: mahlerfive is an unknown quantity at this point 
Solved Threads: 16
mahlerfive mahlerfive is offline Offline
Junior Poster in Training

Re: Recursion Help

 
0
  #3
Dec 10th, 2008
I would argue that the majority of code people write is iterative rather than recursive. Because recursion has more overhead in terms of memory and speed, iterative approaches are generally preferred unless the recursive version is much simpler to understand and implement. I'd say the biggest downside to recursion is that function calls require stack space which is usually very limited, and if you try to recurse too deeply you will stack overflow and crash your program (try recursing a million times and you'll see).

I find recursion simpler to understand when it's applied to some sorting algorithms (mergesort, quicksort), and tree structures (you will see these in a data structures course). Of course, when you first start learning recursion, almost every problem will seem easier to understand iteratively. Once you gain more experience with recursion it will become easier to understand.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC