AHHHHH!!
We just got introduced to recursion and at first glance is the most confusing thing I've ever seen.
To be quite honest not having a lot of programming experience and the combination of recursion has real distracted me.
Friday, 28 February 2014
Thursday, 13 February 2014
Recursive Tree Lists
This week we mainly discussed tree methods that work with the trees. I previously worked with search list in the labs which i understood and was able to complete but the tree list was like maybe 10 steps ahead of that. We learned that a leaf is a node with no children and a root is parent with no parents and a child could be a tree but all the last nodes are children. We than learned about post order and in order traversals which are two different ways of representing the nodes in a tree.
We did a lot of recursive functions in class that were fairly similar but accomplished different thing.
We worked with list comprehension in a lot of the function while working with tree lists.
In comp sci, a binary tree is a tree data structure in where each root can have a max of 2 children. The children ar In a binary tree, the degree of each node can be at most two. Binary trees are used to implement binary search trees and binary heaps, and are used for efficient searching and sorting. A binary tree is a special case of a K-ary tree, where k is 2.
In comp sci, a binary tree is a tree data structure in where each root can have a max of 2 children. The children ar In a binary tree, the degree of each node can be at most two. Binary trees are used to implement binary search trees and binary heaps, and are used for efficient searching and sorting. A binary tree is a special case of a K-ary tree, where k is 2.
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!
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!
Subscribe to:
Posts (Atom)