Monday, 10 February 2014

CONQUERING RECURSION

So recursive functions
Its when you create a function and call on it within its return statement.
Recursive functions have 3 parts in general
the base
the recursive
and the work.
the base is the simplest part of the functionthat requires no recursion at all. this is usually the first if statement,
the recursive are the recursive function within your function to make your work easier,
the work is what youll have left after youve recursed and use he smaller data to work with.
Its like when you do something in a function then manipulate it and then call on it again and again till it reaches an else statement. if not it will loop infinitely. which is like super duper bad.
its like the factorial example which gave me my eureka moment
its like 5! is the same as 5*4*3*2*1
but with recursion you can just cal 5 *4! and it will work the same because it recursively got the 4! number.
Recursion saves time energy and effort
I finally got it!
Like I had an epiphany and I can shout it out off the top of mountains!!!!!
Seriously though... I feel like I was in a black hole because I didn't grasp it sooner.
I think the main part was making my brain forget what it already knew. I was stuck trying to put my "csc108 for loop" into the recursion somehow. I had to kick my brain out its comfort zone to finally get out the old habits.
RECURSION!!!! erm.. uh.. yea.. Had another outburst...
I don't think the world can even fathom how happy I am to have been able to grasp recursion.
And search lists, I think that was the only lab I can say I took charge of with confidence!!
I think Im on a roll ...
And Pre order traversal to all whom don't understand I think is like left subtree then right subtree and then in order doesn't seem in any kinda order to me to quite honest Im gonna try and look into that so hopefully the next time i check in there will be more of it to come!

No comments:

Post a Comment