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

  • From: "black ares" <matematicianu2003@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 8 Apr 2011 10:58:20 +0300

yes, but it use recursion:)
So, because others have done tools we can use, that does not mean that 
programming methods are of no use.
Because in the tools we use, the programmers used that methods.
So the serialization of java is based on recursion.
And in case you will be in the situation to write one serialization tool you 
must know recursion.

The recursion is strictly linked by the concept of tree.
So if you don't use trees, or graphs, may be you will not use even recursion.
but pay attention that, trees are hidden behind a lot of things, things that 
you even don't realise that there might be a tree.
For example the fastest sorting algorithms use recursion.
Do a similar sorting algorithm using iterative way.

I know, you will say that java has a sort method...
I know...
But in this manner nothing in programming is usefull novadays and we become 
simply tool users.


  ----- Original Message ----- 
  From: Stanzel, Susan - Kansas City, MO 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Thursday, April 07, 2011 8:31 PM
  Subject: RE: Java Questions Again: What's So Great About Recursion


  Hi Listers,

   

  Java has a serialization mechanism to do that kind of tracking.

   

  Susie

   

  From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Homme, James
  Sent: Thursday, April 07, 2011 12:16 PM
  To: programmingblind@xxxxxxxxxxxxx
  Subject: RE: Java Questions Again: What's So Great About Recursion

   

  Hi Ty,

  Is it done when it has finished reading the file?

   

  Thanks.

   

  Jim

   

  Jim Homme,

  Usability Services,

  Phone: 412-544-1810. Skype: jim.homme

  Highmark recipients,  Read my accessibility blog. Discuss accessibility here. 
Accessibility Wiki: Breaking news and accessibility advice

   

  From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield, Tyler
  Sent: Thursday, April 07, 2011 12:59 PM
  To: programmingblind@xxxxxxxxxxxxx
  Subject: Re: Java Questions Again: What's So Great About Recursion

   

  Jim:
  Recursion has a limited number of applications where it is actually more 
useful than a loop, I'll give one I use it for.
  In my game engine, properties are stored in a tree setup with a root property 
and all other properties work from there. so, you could essentially have 
stats.health, stats.mana, etc. stats is the root node, health are the children 
nodes on stats.
  Now, here's where recursion comes in handy.
  when I serialize this tree, I write it all in xml. so I'll serialize the 
stats, then I'll serialize health. what I do is something like this:
  Serialize(XMLNode, property)
  so lets say that stats.health has two properties: stats.health.hp, and 
stats.health.max_hp. in order to serialize that I would have to loop through 
the properties of stats.health, then if hp were to have another property I'd 
have to loop through those, which could get messy.
  Rather than do that though, I use recursion. so the serialization setup calls 
serialize on stats, passing the root, then that function calls serialize on 
stats.health passing health.
  I hope I explained that properly. Essentially in summary, it allows me to 
keep passing in each node of the tree until I am finally done. I can recurse 
until I get done serializing a branch, at which point I will pop back to where 
i was because the recursion will return when it's done.

  On 4/7/2011 10:51 AM, Homme, James wrote: 

  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. Discuss accessibility here. 
Accessibility Wiki: Breaking news and accessibility advice 

    


  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.





--  Thanks,Ty

Other related posts: