• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Recursion on Android

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Don't know if anyone ever considered this, but is implementing recusion on android ever a good idea? I know recursion is something that should be avoided whenever possible, but the algorithm I'd like to implement will be a lot easier with recursion.

I was just worried about the stack in general.


 
Rancher
Posts: 43076
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I know recursion is something that should be avoided whenever possible


This is just wrong, plain and simple. There's nothing bad about recursion in itself. If the algorithm is recursive (like QuickSort), then, by all means, implement it recursively. Looking at code that implements QuickSort without recursion is just nasty - don't do that! I have held forth on this subject before, you should read those topics for more information: https://coderanch.com/t/422207/Programming/Why-recursion and https://coderanch.com/t/5200/Cattle-Drive/Recursion. There are big differences between linear recursion (might be OK) and tree recursion (probably bad, unless there are definite limits on tree growth).

I don't think that there's anything Android-specific about whether or not to use recursion - yes, mobile devices tend to have less memory available, but if a recursion takes up that much memory it's probably inappropriate to use anyway.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic