Wednesday 1 April 2015

Week 12: Last Impressions

Hello,

This is going to be my last post for the course CSC148. We just finished our last week, with a brief overview over code efficiency. We looked at some sorting algorithms and compared how they would differ in time when being given a list of length n. When n got large some algorithms would would grow quadratically such as bubble sort. While merge sort grew at nlog(n) speed while n grew.

We looked over Big Oh a lot more in detail in CSC165 last semester, but it was interesting to learn some of the applications of the things we learned in this course to Big Oh. Such as some of the abstract data types we learned. If we were deleting an object from a linked list it would be in in O(1) which would be faster than a normal list. Or if we are searching for number in a binary search tree it would O(log(n)) which would be much faster than a list which would be in O(n).

http://xlinux.nist.gov/dads/Images/bigOGraph.gif
<a graphical, visualization of big oh>

Looking over the rest of the course, I learned a lot and enjoyed this course very much. This course really explained the problem solving and abstract part of computer science rather than CSC108 which was mostly learning about python convention and the tools of programming.

My largest struggles over the course was tracing and learning to write recursion. It took me a while to understand but eventually I got to the hang of setting a base case and understanding how the function should consider different input because it is calling itself, in itself. The fact that I became comfortable with recursion makes me feel pretty confident in continuing computer science and trying to face many other challanges that come my way.

What I really enjoyed from this course is learning the different types of ADT's and applying them to different problems. Trees, binary trees and linked lists can solve particular problems, but the good thing is that they can be applied to many other problems to represent data. Hence the name abstract data types.

I really enjoyed this course and I would strongly recommend it to anyone is interested in computer science. I am sure when I am continuing computer science in the future I will look back to what I learned in this class and it will help me in my future years.


Thanks for reading,
Rod Mazloomi

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 

Thursday 26 February 2015

Week 7: Summary of Abstract Data Types (ADTs)

Hello,

A new concept that I have been introduced to this year was abstract data types. I never thought that these data types would exist. I thought that most programming data was just held in the common int, str, list and dict. But after learning more about these data types I learned that they added more functionality to accessing data, searching through data and writing data. The types of ADTs we learned so far are:

Stacks:
I like the title stacks because it describes how the data type works. New stacks can only be added from the 'top' and data can only be read from the 'top'. What helped me understand this data type is thinking of stacking rocks. If you want to add data to this stack then you cant add a rock to the bottom because the tower is going to collapse, so you add it to the top of the stack. Same if you wanted to take a rock off of the stack and examine it, you can only take it off of the top to examine so the tower does not collapse.


Queue:
A queue is a little different from a stack. What helped me understand this data type is thinking of a line up at a restaurant. If you wanted to add some data to this "line up" then you cannot add it right at the front of the queue (unless it is empty) because you will be cutting in line. If you wanted to read data from a queue then you take from the "front" of the line and not from the back because the data at the front of the line has been waiting there.


Tree:
A tree is quite unique in that it contains nodes that store data but has "children" that are also nodes that store data and could have children as well. Just from seeing this you can tell trees have a recursive design to them. That trees contain smaller trees that contain smaller trees. So you can see if you would like to access data in a tree recursion could used to run through the similar nodes of a tree. What helps me think of a tree is a an upside down tree that branches out with its nodes that contain data types. If a node does not have any children than it can be called a leaf.


Binary Tree:
This is similar to the tree. The only difference is that nodes in this tree have up to and including 2 children only. This tree can be much more useful when holding data such as arithmetic operators that have children of numbers that they want to use the operators on since you addition, multiplication, subtraction and division take two inputs.


I hope you understand my interpretation of these ADTs well, and that they were not to confusing. I am sure the learning ADTs they will help me a lot more in the future when working on several projects on methods of storing data.

Thanks for reading,
Rod Mazloomi

Wednesday 11 February 2015

Week 6: Summary of Object Oriented Programming Concepts

Hello,

I am going to be summing up what I know from object oriented programming. I will start off by sharing a quote I found:

"Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data." [1].

Even though I may not know everything about object oriented programming, I can still relate to the quote based off of what we learned in lecture so far. What we have been focusing a lot on so far are creating objects and recognizing what makes up a object. An object has attributes and verbs(actions) which we can implement in to code to 'create' this object.

For example the class Student may have attributes: name, student number, year and grades.
Some verbs may be: find an average mark of the student, enrol the student in a course (may involve another class) and so on.

http://www.derekyu.com/tigs/forums/tutorials/gmtut/gmtut-008.png
Also involving inheritance we learn that objects are not entirely unique and that they share common actions. What helps me to think of inheritance is to think of traits being passed down. Such as like species passing down dominant survival characteristics down to future generations in The Theory of Evolution or another example may be parents passing down similar genes to their children.

Thinking about problems using objects is quite tough at first but I am sure over time I will get better designing such programs that uses object oriented programming.

Goals for the future may to learn some procedural programming so I can a have larger perspective of other programming styles.


Rod Mazloomi

1. Margarat Rouse, object-oriented-programming (OOP), <techtarget.com>, August 2008.