| | |
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 |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows





