Just to comment on the recursive function mentioned above:
In general it is NOT advised to use recusiveness .
It has several disadvantages, which can be very serious problem depending on the code base.
Generally it is advised to use a stack instead.
(This is not to say recursion has no place at all, but for most cases you get only drawbacks and no benefits from recursion)
Bookmarks