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.

Tuesday 3 February 2015

Week 5: Tracing Recursion

Hello,

Last week we started learning about recursion. We began by tracing calls on recursive functions. I found this really self explanatory and fairly easy, but I am sure knowing how to trace a recursive function call is going to help me write my own resursive functions.

In last weeks lab in the last exercise we were given a problem that we were supposed to solve recursively. We were supposed to find the maximum sublist length in a list that may contain other lists. At first it I did not understand how to solve this problem and it did not make sense to me. So i was trying a lot of trial and error with code trying to get this program to work and it was not working. So what I did is just left the problem for a while and just thought about it, and after a while I came up with the idea in my head. I translated my design into code, implemented it and ran it and it worked perfectly with all the test cases I gave it.

I was pretty happy because it was the first recursive function I wrote and maybe one day I will look back to that day and remember the first problem I solved using recursion.

- Rod Mazloomi

http://upload.wikimedia.org/wikipedia/commons/thumb/4/45/Sierpinski_triangle.svg/2000px-Sierpinski_triangle.svg.png