RE: Java Questions Again: What's So Great About Recursion

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 8 Apr 2011 07:35:59 -0400

Hi Black,
Thanks. This is the most useful answer I have had on this topic. I will read it 
over and think about it. Thank you for trying to put this in non-programming 
terms and for not displaying your ego.

Jim

Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Highmark recipients,  Read my accessibility 
blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. Discuss 
accessibility 
here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. 
Accessibility Wiki: Breaking news and accessibility 
advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx>

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of black ares
Sent: Friday, April 08, 2011 3:40 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Java Questions Again: What's So Great About Recursion

Hello,
A metod is not good only because it solve a class of problems,
but even for introducing an easier way to do things.
By easier I mean a lot of things, starting from the written code up to more 
elegant algorithms.

How ever, a loop is able to go forward until a condition is no longer valid, 
but there it stops.
Recursion ofer you the ability to go back if a condition is no longer valid, 
return until that condition becomes valid again and from there to continue, 
with another set of data, to go forward until the condition becomes again 
invalid.

Also the recursion allows you to go forward until a condition is no longer 
valid like loops, but also allows you to do some things on the way back to the 
start point.

For example, think to the following problem:

I have a City and in that city there are paths to go from a point to another.
How can I get the set of points available starting from a starting-point.
Try to do a recursive algorithm and after this try do do an iterative one and 
see which is easier to implement, to code and to write.

The recursion is good when you don't know from the begining how many levels you 
must go or when the number of levels change dinamically.

how ever, you must learn about it because, some time, you will get to a point 
where iterative solution does not exists and you will remember to use recursion.
For example, in my career, I had to implement sort of "counters".
But the number of the digit of the counter was a configurable parameter.
So from the begining I didn't know how many digits that counter will have.
To do a counter, the simple variant when you know the number of the digits is 
to do as many fors as number of the digits.
But when you don't know the number of the digits from the begining?



----- Original Message -----
From: Homme, James<mailto:james.homme@xxxxxxxxxxxx>
To: programmingblind@xxxxxxxxxxxxx<mailto:programmingblind@xxxxxxxxxxxxx>
Sent: Thursday, April 07, 2011 7:51 PM
Subject: Java Questions Again: What's So Great About Recursion

Hi,
It's probably my ignorance coming out to bite me again, but I just was reading 
about recursion in my Java book and thinking that it isn't all that useful 
because you can do the same stuff with a loop. Maybe the book examples are so 
simple that I just don't see it's usefulness. They were even saying that 
recursion eats up more memory than loops do, so I'm wondering why I learned it 
in the first place, other than to know how it works and that it exists.

Please help.

Thanks.

Jim

Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Highmark recipients,  Read my accessibility 
blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. Discuss 
accessibility 
here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. 
Accessibility Wiki: Breaking news and accessibility 
advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx>


________________________________
This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.

Other related posts: