Sunday 5 April 2015

Wrapping it up

We made it! The course is over, all assignments submitted, only the final exam left!
Every course I've taken in my first year of university has been nothing like I expected it to be. There have always been surprises, some good and some bad, but it's always been something new and unexpected. This course was no different, but I definitely liked it much more than some of the other courses I have. Computer Science logic is something that I understand and find interesting. This course just helped me understand all the concepts, recursion, trees, linked lists, etc. even better. I might have procrastinated over the assignments and panicked over minimax but at the end of it all I think I'm taking a lot of useful information away form this course. I hope my concepts are now solid enough for me to be able to survive the next 4 years in CS and do this course proud.
So that's the end of yet another semester, and with that the end of honestly one of my favorite courses in university(because I somehow have pretty good marks in this muahahahaha). I hate to end on a not-so-happy note but...
Good luck!

Saturday 28 March 2015

Revisiting Trees

Building up on my post called 'Trees and Branches', I realize that the use of trees in in this course is more frequent than I thought it would be. When at first we were just learning the basic concepts of trees and recursion, I never really imagined that those concepts could be used so extensively in places such as our assignments where we come up with game states and strategies. Every game played for our assignments can be drawn out in full, with every possible move listed, as a tree. Looking at the games in such a way makes it so easy to recursively go through each possible game states to do such things as find the longest path a game could take to finish or to see how many possible outcomes of a game would cause a specific player to win. This is what we have to do(at least for part B) in our last assignment of the course. The idea of trees remains the same but over the course of the semester we've started using trees and recursion as basic necessity. The concepts that I found confusing before, those of arity(the number of children), height(the maximum length path plus 1, I always forget the 1), etc. have become increasingly clear to me  through their usage in labs and assignments. Assignment 3 even has a function, branching_stats, that requires us to recursively calculate the different branching factors in a tree of a game and all that didn't make sense to me before makes sense now.
Which reminds me, assignment 3 is nearly done, one more week to go, woohoo! The finish line's right around the corner y'all!

Sunday 22 March 2015

Oh Bugger

We didn't do much in lecture this week except for go over minimax and understand how it's supposed to work.
One new thing we looked at was the assert statement. It showed up in the code for one of our labs and I everyone was pretty confused as to what exactly what its function was. Technically, if you think of the actual meaning of the word 'assert' you can yourself assert(aha see what I did there) what the statement is doing; it determines if a condition is met and raises and error if it is not. Its a useful tool to keep track of errors in loops and such. I honestly do not understand why or how it is more useful than just normal error checking practices but I think I need to use the concept a bit to be able to grasp it fully.
The other thing we covered this week was how to trace through complicated code that has function calls within itself. This helped me understand the multiple call system of recursion a bit better. Using the debugger is really a great way to visualize how python works and what steps it executes first. It helps you change your way to thinking as python would think so that you understand how to code your problem. Just keep stepping over how many ever times you want, its as helpful as pictures for recursion. Don't make the same mistake as Chuck Norris

Sunday 15 March 2015

Midterm take two

Another midterm gone by! Another step closer to the end of the course!
This midterm was better than the first one for me. I anticipated a time shortage based on my experience of the first midterm so I knew this time I had to think faster and write quicker. Recursion was the main concept, so the key here was thinking quickly of the cases and recursive format because writing it out is then does not involve too much code. I'm not a hundred percent sure how I did on the recursion part but I know that I got the first question wrong. What confused me was the part that binary trees can have just one child, it does not have to be filled completely on every level. So the largest height a binary tree with 20 nodes can be is just a long chain of nodes with the height being 20. The exam on the whole was again, pretty straightforward, another milestone in the course reached!

Sunday 8 March 2015

When Minimax was nearly the death of us

Another data structure!
Linked lists might not be a basic data type but they definitely have their advantages. The most annoying thing about them, I think, is that you have to travel through the list element by element to get to any value in the middle. But they do still form a nice chain-like structure that follows a concept similar to that of recursion, a concept of repetition. To get to any value you have to repeatedly go through all the values before it.
One thing that I realized for both linked lists and recursion is something that I found at the end of this guys/girls slog here:
http://1024forbidden.blogspot.ca/2015/03/week8-assignment2-about-recursion-and.html
i.e pictures help. A lot. Its easy to overlook this approach while solving recursion and linked list examples but I've found more often than not that explaining or understand something through a picture makes its so much easier to grasp.
That was one thing that I messed up on with the second assignment. I'm sure a lot of us were taken by surprise by minimax. I didn't think it would be that difficult so I procrastinated and left it till pretty much the last day. Which, of course, was the worst possible decision I could have made then. I also didn't draw pictures or try to understand the concept properly which in retrospect I should have done. But somehow, more than minimax, I found trouble coding the game state for tippy. I just could not understand how to store the data of a single game state in an accessible manner. I think I made minimax work by the end of it but our tippy game state was definitely a failure.  But oh well, all we can do is learn from our mistakes and move on!

Here's to (hopefully) a better assignment 3. 

Sunday 1 March 2015

OOP

Seeing as the topic I've talked about in my Slogs for the past couple of weeks has been recursion, I thought for this week's specified topic I'd shift tracks to OOP(Object Oriented Programming). As I think I may have mentioned in one of my earlier posts, OOP is the basic concept for most programming languages. For the two that I know so far, Python and Java, it is definitely something that forms the core of how these languages function.
In Object Oriented Programming, as the name suggests, everything is essentially an object. Whether it be a variable or a method or a class; they are all treated as objects, similar to how we use objects in the real world. These objects then interact with one another through the code to form an overall main structure or to maybe even form another object. The idea of OOP includes an object being an Abstract Data Type(ADT) and also having the property of inheritance, two concepts that we have studied in this course. Abstract data types that we have learnt about such as Stacks, Binary Trees, and Binary Search Trees are all objects themselves i.e. every stack is an object as is every Tree. Objects then also have hierarchies which means that inheritance enables one object to obtain the properties and functions of a parent class(as we have seen in our assignments with there being specific game states and strategies that inherit from the basic parent game state and strategy). Furthermore, OOP involves keeping the code and the inner workings of an object separate from its user interface. That is the whole purpose of having methods in classes that allow certain functions to be accessed through them while keeping the 'how' of the working separate.
All the programming we have done so far in the course has been object oriented. Something that I have noted is that what people tend to do when they first learn coding is to put all their code in one place, that is in the main program. This way of not using classes or methods does not utilize the full power of OOP. The code ends up being all over the place when it could have been put together and organized in methods and classes. Moreover, this prevents reusing code for say, recursion, or even more simpler things. Were we to do any of our assignments in just one single main program, the resulting code would be horrifically disorganized and very difficult to understand even to the person who coded it. Hence the advantages of OOP, unlike recursion, might not be that visible or that fascinating, but they still have great power in coding which needs to be understood and used properly. 

Sunday 15 February 2015

Trees and Branches

First of all, getting those midterm marks back was a bit scary I'd say. The first one is honestly always the worst one for me because it sets the pace for the rest of the semester. So I guess it's a good thing I didn't do bad on this midterm. The class average is in the high 70's though, and I think that's a pretty decent mark for us all to be averaging around.

Now getting back to the more important stuff, the implementation of recursion in data structures, namely Trees. To be fair, I did learn the basics of this in high school comp sc so I can't really tell how difficult a concept this is right now for everyone to grasp, but I feel like it's not that terrible. The whole idea behind recursion is to break down a problem into smaller versions of itself and that is exactly how we apply it to trees. Break the branches down till all you have left are trees with just one single node. The terminology involved with trees is a bit more confusing than I thought it would be, with arity and branching factor, and the height and the depth but I think it'll become pretty clear after a while of working with trees.