Sunday, 29 March 2015

Looking back on recursion

Looking back on recursion, I'd say I still pretty much agree with what I had discussed previously. Something I didn't quite get the grasp of was the idea that every time you enter a new 'node', it is a new recursive call. For example, if you are trying to recursively go through a tree, every time you enter a new node, you temporarily leave the previous recursive call and enter a new one and rerun that function.
For example, if were to recursively go through this tree inorder, we start at 2. Inorder says we must look at the left subtree, the root and then itself. So starting at 2, we enter the left subtree which is 7. This just opened a new recursive call. We're not going to go back to 2. We're going to go to the left again. This 2 opens a new recursive  call and since 2 has no left, we return 2 and since it has no right children, we return to 7 and return that. Then we enter the right subtree and repeat the process.  In the end, the answer should be: 2, 7, 5, 6, 11,  2,  5, 4, 9.

I have commented on a few slogs for this particular topic:
  • http://csc148justinsong.blogspot.ca/2015/02/week-7-summary-of-recursion.html
  • http://nailedcsc148.blogspot.ca/2015/02/impressions-of-tracing-recursion.html
  • https://colslog.wordpress.com/2015/02/08/recursion/

These sloggers for the most part had the same ideas as I did when it came to recursion. In its most basic form, recursion is simply when a function calls itself within its own function but it is important to have a base case or we will have an infinity loop.

I also liked the way these sloggers approached problems. one went to another website for more information and others just worked with it over and over again until they understood.

I think what most people had issues with was the strike. It was really hard to get the help we really needed but I believe most of us pulled through.

No comments:

Post a Comment