| | |
Recursion Help
![]() |
•
•
Join Date: Dec 2008
Posts: 8
Reputation:
Solved Threads: 1
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 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
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.
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
•
•
Join Date: Aug 2008
Posts: 77
Reputation:
Solved Threads: 16
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.
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.
![]() |
Similar Threads
- Recursion: when do you use it? (C++)
- C++ Beginner - #include recursion problem (C++)
- Recursion (C++)
- number formatting using recursion (Java)
- Need help with recursion and arrays (C++)
- powers of two, recursion. (C)
- Create menu from properties file by recursion (Java)
- Recursion (C)
Other Threads in the Java Forum
- Previous Thread: Tokenizing null pointer error
- Next Thread: MySQL rollback problem.
| Thread Tools | Search this Thread |
actuate add android api applet application applications array arrays automation balls bank binary bluetooth business chat class clear client code codesnippet collections component database defaultmethod development dice digit dragging ebook eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health hql html hyper ide idea image infinite int integer invokingapacheantprogrammatically j2me java javame javaprojects jni jpanel julia linux list main map method methods mobile myregfun mysql netbeans nonstatic openjavafx parameter pearl php problem program project recursion repositories scanner scrollbar server set sms sort sorting spamblocker sql sqlserver state storm string sun superclass swing swt thread threads tree windows





