Friday, 20 February 2015

Recursion Take Two

Even though I've practiced it a couple of times, recursion is a challenge I continue to hate. In Assignment 2 I was forced to implement a recursive function but I'm still a bit iffy about it. Its not impossible to write a recursive function because of the steps that have been nailed into my mind; Step 1- What is the base case?, and step 2- Take the base case and make it recursive. As simple as that may sound, writing a recursive function is a bit tricky.

I love to trace a recursive function, I can do that in my sleep haha, but the thought of writing a recursive function is a challenge that I don't want to face, even though i know it will reappear on the second midterm.

The base case if you didn't know by now, is the simplest case that doesn't require recursion, it usually will be part of an if statement, that returns a generic statement such as; Return False, or Return 1; and after that the 'else' statement is the recursing one. Through my experiences when writing a recursive method on trees, the recursive part is usually [ method name (x) for x in [child or node...etc]]. As struggling as a recursive method may be and the fact that I haven't really used it unless told too, I fell recursion is a tool I should wield in my computer science tool belt.

Monday, 16 February 2015

Object Oriented Programming

    Coming into CSC148 I did't know much about objects and how they were seen when coding, but as the course progresses I think i'm getting a better handle on the unique concept. If I am not mistaken, and if I refer back to the diagrams Diane would draw on the board when she explains objects in code, I think objects are chunks of memory that the computer reserves for certain data. I remember Diane would draw boxes and call them objects, and when she would refer to it she would connect the boxes with lines, and that is the design of objects that come to mind when I think of objects. All in all though, I think that knowing how objects work, the imaginary function, creation and implementation of objects are a valuable assets for computer scientists, since they can always use it when they're lost in the jungle of their own code.

   As the course progresses I hope to implant and fortify the idea of objects in my mind for future courses, but to this day i think objects are these chunks of data that reserve information and values in them, and if i am ever confused about objects and how they're data types are assembled i refer to the python visualizer

Sunday, 8 February 2015

reCURS[E]sion

I've found recursion to be like a maze. A maze that can trap an individual if it is not traced through to perfection. But as we work through recursion in class I've learned that recursion is a tool that every computer scientist should have equipped in their tool belt. It's capability to turn code from 15 lines of reoccurring for and while loops, and if statements, down to 4 lines of recursing code, just proves that it can change anyones code...IF USED CORRECTLY. I've learned it the hard way, but trying to use your own form of recursion can leave your computer in an infinite loop, forcing you to force quit Wing and risk losing all your code. Hopefully in the upcoming weeks I'll learn how to write my own recursive function and shorten my very own code.

As difficult as recursion is, I have figured out a couple of tricks when tracing through a recursive functions, well through the examples we've been presented with in class. First, I've learned is that most recursive functions start with a conditional statement, Ex: If L is list, or X is str, so by going through that first and seeing what parameters are being passed into the function, sometimes you don't even have to proceed to the recursive part. But sometimes we do have to trace through the recursive part, and when this happens another pattern that I've seen -or maybe that's just how recursive functions are written- is that after the initial condition fails, the proceeding part has a For Loop. When tracing through the for loop, I treat it as if I'm performing the distributive property with the function, onto each element of the iterating portion of the function. By doing so I prevent myself from getting stuck in the maze of a recursive function. Follow these 2 rules, and I know anyone can trace through a recursive function as easy as I do.

Saturday, 7 February 2015

My first few weeks in CSC148

       I'm writing this blog a bit late, and it has been 4 weeks in CSC148 instead of 3, but entirely this course has been an eye opener for me. Since computer science isn't my declared major or specialization - I'm doing it as a minor, I'm currently in Rotman and hope to specialize in Accounting- I haven't prepared throughout high school for courses like this. My mentality when I started this course was similar to any other non-computer science student. When given a problem to solve in class or an assignment, I would tackle it head on, I assumed that if I did this problem once before the process to answering it again would be the exact same. But in CSC148, I've learned that that isn't always the case, that there are multiple ways to solve the same solution, all of which are correct. Over time in this course as the weeks progress and the lectures begin to accumulate, I am learning more about the course and how to program as a professional, but I am also learning how to solve everyday problems, through analytics and looking at a situation from all perspectives.

       CSC148 has been a unique experience thus far, and it continues to grasp my attention with all the neat  things were are able to do simply by coding. I am guaranteed that every week I learn a new topic or I further enhance something I thought I already knew. It is learning environments like the ones CSC148 creates, that make UofT a world recognized school, if not lectures, then it is the amazing TA's that assist you throughout the labs; even the assignments so far have been fun..once you understand what you have to do. I can only imagine that with this path of computer science, where I will end up.