Friday, 8 April 2016

CSC148 Week 12

It hit me today that first year is officially over. This week is the last week of second semester which means this will be my final entry. This course has been quite a ride. In the beginning of the year I totally underestimated the course because of how easy CSC108H1 was. Now I actually take it much more seriously. Overall I thought the course was a healthy challenge.
This week we learned about how to trace your code. It is quite simple, yet very effective when checking to see whether code works or not.

Wednesday, 30 March 2016

CSC148 Week 11

So I was looking back to my week 4 entry, and I noticed that some of my opinions have developed a bit. I said that I had to change my study habits in order to do decent in this course. I was correct about this, but in order to do great in this course, it takes a lot of dedication, practice, and question asking to get a great mark. Since then, changing my study habits has lead me to do much better on the second test than on the first test.

I've also stated that I found unittesting to be "complicated and confusing". I still agree with myself on this. I prefer just putting tests in my docstring (you'd use doctest to test them) since they're usually short anyway. It's easier and saves a lot of time. On the other hand, unittest is great for when you need to do a really long test for a method. Putting such a test in the method's docstring would just look silly because of its length.

Friday, 25 March 2016

CSC148 Week 10

This week was pretty eventful, we were able to see our test 2 marks on cdf and we had an assignment due on Thursday. I did significantly better on test 2 than on test 1, so I feel happy about that.
This week in lecture time we learned about Algorithm efficiency. What specifically caught my eye was memoization. Memoization is a technique that is used to speed up program efficiency by eliminating redundant function calls. This technique still allows the function to produce its expected output each time. For example, Let's say you have a recursive function called f(int_num) that constantly produced the call f(30). Let's also say that f(30) always evaluated to the same integer every time it was solved by the function. So then, why bother letting the program waste time to evaluate f(30) when you can just store the value of f(30) (in a dictionary for example) and replace any f(30) calls seen in the future with its value? This technique would save a lot of processing power.

Friday, 18 March 2016

CSC148 Week 9

This week we had our second term test on Wednesday (March 16). It covered LinkedList, LinkedListNode, Trees, Binary Trees, and Binary Search Trees and recursion. I thought the test was pretty fair, we had more than enough time to finish it and all the questions were answerable.

During lecture time, we learned about Binary Search Trees this week. A Binary Search Tree is a Binary Tree where each node has up to two children, a right child and a left child. A node's left child is less than the node's data and a node's right child is greater than a node's data. A Binary Search Tree can be used to find a certain value more efficiently than if you were to find the value in a Binary Tree or Tree. For example, if the value you want to find is less than the root's data, this means that the node you want to look for is to the left of the root. So you'll want to look at node's left child, and then their children, and so on, until you find the value you're looking for. If you had to look for a value in a Binary Tree or in a Tree, you'd have to check the value of every node within its structure. We also learned about inserting a node into a Binary Search Tree and deleting a node from a Binary Search Tree.

Friday, 11 March 2016

CSC148 Week 8

So this week I learned a bit about BinaryTrees. BinaryTrees are Trees in which all of their the nodes have 2 children. We also learned about Binary Search Trees, which is basically a BinaryTree where at generally any node, (let's assume the node we pick has two children and that the node has a float or int value) the node's left child is less than the node in value and the node's right child is greater than the node in value.

In this weeks lab we had to work on functions that worked with Trees. I took a whole evening to struggle with the material. I found the lab to be a bit challenging, especially the list_internal function. By the following morning, I felt the material start to sink in!

Wednesday, 2 March 2016

CSC148 Week 7

For the majority of this course, we've been introduced to many different kinds of commonly used abstract data types such as queue, stack, sack... and so on. An abstract data type is a data type that can be created by a user. This data type has its own behavior, has its own data, and has its own operations that manipulates/interacts with their own data. During this week we learned about a new abstract data type called Trees.

You can imagine a Tree as a data structure with a chain of nodes that can be imagined as a hierarchy. A Tree's nodes store one value each. (i.e. 7) Some nodes lead/refer to other nodes, and some nodes don't refer to any other nodes. Nodes that don't refer to other nodes are called leaves, since they are "childless". All trees have a starting node called a root. Every node in a tree is a descendant of the root. The root itself is the only node in a Tree that doesn't have a parent. Here's an example of a tree with each node being represented using parentheses: (1) has three children, which are (2), (3), and (4). (2) has a child which is (10). All other nodes are childless.

We learned that Tree has very basic operations such as __str__, __contains__, __repr__, and __eq__. During this week we've also learned about some (module level) functions that can be used to manipulate Trees or get information from Trees. These module level functions strongly relate to recursion.

Friday, 26 February 2016

CSC148 Week 6

Reading week is over! I honestly wish it was longer, but at least I was able to catch up on sleep.

We started talking about recursion this week. Recursion is a technique in which a method is used within itself. The method is executed many times times (within itself) in order to keep changing certain data. Recursion can be used to make beautiful visuals such as fractals. To have a method work within a method is pretty mind blowing!

We also learned about the one liner version of an if else statement. Here's an example below:
>>> z = 100
>>> z = 10 if z == 100 else print('banana')
>>> z
10

I found the syntax of the one liner version to be confusing at first. It took me a lot of typing in python shell to figure it out/understand it. The above statement literally means: I want z to equal 10 if the expression z == 100 is true, or else print the string 'banana'.