Wednesday 25 March 2015

Week 11: Looking back at Week 5

Hello,

Looking back at week 5, when we were learning how to trace recursion I realized how many things have changed since then. Since then I remember recursion being this scary concept that I heard from upper year comp-sci students that it was tough. Writing the post at that time I never realized the importance or significance of writing recursion in place of writing while or for loops. But now after working with recursion for so many exercises and practices it came naturally. Not in just coding but in solving problems in general. For example recursion can make a problem so much simpler if the same process had to be repeated for an object that had similar instances of itself. When I say similar instances of itself I mean something for example like a tree. A tree has trees as its children that have more trees as their children and they all have the same attributes. Using recursion for something like trees rather than using loops is recognizing that a function can be used on each aspect of the tree. This is not something that I saw before and I think is really important to know the importance of recursion so programers can implement it in their code and their problem solving models.

I agree with everything I said in my blog post of week 5 and I chose that blog post because it is when I wrote my first recursive function that I solved independantly. That day was not only learning about recursion but I learned an important lesson that day. Even though some problems may seem impossible when behind a computer and in the moment, over time if you just think about it while doing daily activities (in my case while eating, while commuting, while showering and before I go to bed... the problem was bothering me a lot!) then problems can be properly internalized and can give your prefronal cortex enough time to process the information in order to make a reasonable solution. And in my case my code worked the first time I came back from over the weekend that I was thinking about the difficult recursion exercise that I had from that lab.

Looking back at week 5 made me realize how much I learned in this course and it makes me glad to know that I am learning something and doing well. CSC148 has been my favourite class that I have taken so far out of all of my first year-courses this year.

- Rod Mazloomi

http://netdna.copyblogger.com/images/critical-thinking.jpg

Tuesday 17 March 2015

Week 10: Impresssions on Week 9: Mutating Binary Search Trees and Midterm

Hello,

Last week we only had one lecture because of the midterm. We talked about mutating binary search trees. We worked on two algorithms insert and delete. The code for delete was really complicated and hard to understand at first, but reading the docstring for the stepes of the algorithm helped a lot to understand what the code was doing. This is helped me a lot so if in the future I write a complicated function that may not make sense at first glance, I will make sure to write the steps of the algorithm the same way Danny wrote in order to clearly identify the steps I am taking in my code.

For the midterm last week I was a little scared because I felt like we learned so little from the last midterm to now. But the questions were fair and they just covered binary search trees and linked lists. All of the questions were questions we saw before in labs just slightly modified to check our understanding. This made me realize the importance of doing the practice labs every week.

http://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Donboscocambodia0001.JPG/280px-Donboscocambodia0001.JPG

Thanks for reading,
Rod Mazloomi

Wednesday 11 March 2015

Week 9: Impressions on Week 8: Linked Lists

Hello,

This week we started talking about a new abstract data type, Linked Lists. As I said in my past post, when I want to start learning a new abstract data type, I usually think of an analogy or a visual accompaniment. Thinking of linked lists as a train with cargo helps me visualize how each node (cargo truck) is linked to some other node (another cargo truck) and so on.

Another way I thought of myself to think of linked lists is visualizing it as a one child tree. Unlike a tree (no limits children) or binary tree (two children) a linked list only has one child. 

Linked Lists were reasonable to learn and not to difficult to understand. The only problem I am having is understanding how to apply my knowledge of linked lists. I can't think of many situation where I would have to represent data in the fashion of a linked list. Maybe later on in the course we would use practical examples of linked lists to see how they may be useful and how they may make data easier to read and write.

Thanks for reading,
Rod Mazloomi

http://www.edgewl.com/images/homepage/railfreight.jpg

Week 8: Impressions on Week 7: Binary Trees

Hello,

Last week we learned about binary trees. Binary trees are just like tree but instead of having any number of children, binary trees only have two (left child and right child). I learned some pretty neat applications of binary trees that I never thought would be possible with trees:

Arithmetic Expression Trees:

What is puzzled me when I was a young programmer in grade 10 was how to represent data that  required special ordering in mathematical expressions. This is when I was trying to program a scientific calculator and it was not working out because I did not know how to represent data such as [(4 + (3 * 7)) - (5 / (3 + 4)] + 6.
But learning binary trees last week helped me understand that we can break this bigger problem in to sub problems and evaluate it in a tree. If we understand that each arithmetic operator (+, -, *, /) takes two inputs and has one output we can represent this in a node. Where the value of the node is its operator and its children can either be numbers or outputs of other operator nodes. This makes the problem shown above alot easier to represent on a computer and evaluate.

https://www.eecs.berkeley.edu/~bh/ss-pics/parse0.jpg
 Binary Search Trees:Another useful function of binary trees are making them function as a binary search tree. When I say binary search tree this means that for every node in the tree its left node is less than the node value and its right node is greater than the  node value. Why is formatting the tree in this way useful? Well if you want to search for a number in the tree instead of checking every value from start to end (linear search). For example if we wanted to search for 7 in the tree below we make an algorithm that does the following:- if node value is equal to 7 return true- if node value is less than 7 recursively check the right child- if node value is greater than 7 recursively check the left childDoing this will make the search MUCH faster than looking through every element. This will make you find the by just following a branch of the tree. In fact this seach runs in big omega of log n. Where linear search is n run time.  http://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Binary_search_tree.svg/2000px-Binary_search_tree.svg.png So these are two examples of how binary trees are really useful. This is the main thing I learned last week.   Thanks for reading,Rod Mazloomi