Thursday, March 31, 2016

Week 11 (A look back into the past)

For this weeks slog, I will be revisiting about what I wrote for my first slog in this years course. In my first slog, I talked about how this was my second time being enrolled in CSC148. The first time I dropped out because I lacked passion and motivation for the degree as a whole and planned to switch into another program. All summer, I thought over and over again about what degree I would like to pursue for my future. Math was definitely one of them as I simply loved solving equations and working with numbers. Physics was another because ever since I was a kid, I always wanted to explore the universe and learn about its concepts. The Universe and its stars always fascinated me and compelled me to go star watching on a clear night. Yet, in the back of my mind, I always thought about giving programming another chance. The first block of code I ever wrote was in Microsoft Visual Basic 2008 and it was to simply print out a line which return the string "Hello world." The very first time I ran that line, I felt like I created something amazing, of course, all 28 of my classmates did so as well and felt the same. However, what I did, compared to the rest of them was play around with the syntax and the methods within the API. It happened four years ago, but I remember it so clearly. First, I made a GUI (graphical user interface), and then displayed the text "Hello world" on there instead of the terminal. Next I implemented a button for when you click it, the "Hello world" text will appear on the interface. The point I'm trying to make was that the first time I coded in my life, I fell in love with it and all of the things you could create with it. I guess what I found frustrating in my first year for CSC148 was not being able to code some of the methods. I guess I didn't seek for help as much that year nor put in my full effort. I decided to give another shot this year and it turned out for the better. To be honest, I understood and learned most of the material from my TA during my lab times. Working on what we learned that week plus having someone explain it to me really made me enjoy coding again because everything eventually worked and it feels like I've improved and gained a new craft. I believe that I can finish this course with a mark over 75 which is more than what I was hoping to get from the beginning of the semester. I've even gone above and beyond and applied to work on a project with David Liu this summer. Overall, I've regained that joy and excitement I once felt when it came to coding and I believe that it's going stick around a lot longer this time.

Wednesday, March 23, 2016

Week 10 (Thoughts on this week)

For this week's lectures, we learned about algorithms for sorting lists. The first sorting method I ever learned in python was .sort() which would order items in a list according to its value (from lowest to highest), or its string (from a to z). For this week's lab, we had to implement different methods to sort a list, some of which was done recursively.

More importantly, for this week, our second and final assignment was due. The assignment consisted of several puzzle game classes which all shared a base puzzle class a puzzle tools class. Since most of the coding was already done for us, we were only required to code the extensions and the fail fast methods for each game. Though we weren't required to do so, I was able to code some of  the methods within the puzzle tools recursively. Overall, our program runs without error which I am satisfied for.

Sunday, March 20, 2016

Week 9 (Thoughts on this week)

There wasn't much to talk about this week other than the test we wrote. The test consisted entirely of binary trees and linked lists that had methods which all used recursion. The biggest challenge I had in the test was writing out the code for the binary tree as I had only studied and review standard trees. In this weeks lab, we didn't do much other than completing a few methods in the BinaryTree class, which in fact, had the same methods as the test. Other than that,I just started working on my second assignment which had to do with coding different types of puzzle games. So far I finished up nearly half of it and probably expect to get it done half way through next week.

Saturday, March 12, 2016

Week 8 (Thoughts on this week)

This week in class we learned about trees (specifically binary trees) and how to code them using recursion. A tree consists of nodes that may or may not contain children. Nodes that contain children are known as internal nodes. Every tree starts at the root, or otherwise, known as the initial node. A tree can consist of simply one node or a million nodes, and each can have any number of children.

I always found trees to be one of the simpler ideas to implement in CSC148. The problem I had last year was coding the recursion that was used in every tree method we defined. Now trees and recursions are something I fully understand. I have to give credit to my TA Phillip Konkulak for probably being the one person who has helped me in this course the most. Each and every lab, we recap what was learned in that week and code it during our lab exercises. On top of that, Phillip would come around answering questions and making sure we understand what were doing.

This week's lab material was probably the most difficult one, but with the help of my TA, I understood it in no more than 15 minutes.

Thursday, March 3, 2016

Week 7(Recursion)

In this week's lectures, we learned about recursion functions. From what I recall, recursion is calling the function itself within the function, creating a loop until a certain condition is satisfied. For me and most of my classmates, the most difficult part of this function coding and implementing the loop (recursion). I still find it quite strange how a method call return a value to itself to use that value. It's python's own version of "Inception".

What we know about recursion so far is that it is a style of coding used inside a method, calling itself over and over again until some condition is satisfied and a value is returned. An example coding of recursion is given below:

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)

Let's say n = 5.

If we take a look at the factorial method here, we can see that it calls itself again within its else statement. From there, it briefly forgets about the n value and will run again with a different n value. As long as n is constant greater than 1, the method it self will iterate over and over again, reducing the value of n each time it is called. Once n has reached the value of 0, the method will begin to return values starting at 1. Once it returns the value 1, the method will jump back to the second last recursion call. Here we will get a return value of 2 * 1, but again, this is a return value to the third last time that the recursive method was called. if  you noticed the pattern, the return values will continue to multiply with one another until it reaches the very first time the recursion occurred which will return a value of 120.

In short, recursion will iterate itself over a number of times from the bottom to the top. We can say that the bottom is the very last time that the method will be recursive while the top is the very first.

Week 6 (thoughts on this week)

I didn't attend my lectures this week because an assignment was due on that weeks Thursday, so instead of writing of my thoughts on this week's discussion, I will talk about my work process for my assignment instead.

The assignment was a simplified version of Uber. There's the rider, the driver, the dispatcher, destination, location etc. we were to use (x,y) coordinates in the first quadrant to determine the location of every driver and rider in the application. Simply put, the rider would request a driver, give a location, and be driven there. If there was no driver, available, he/she would be put on the waiting list. For the driver, the closest driver would be alerted to the nearest rider requesting a pickup and drive him/her to the location of their desire. If there are no riders available, they will be put up as available drivers for the next rider. 

Most classes were simply filling in of the __init__ method along with other standard methods as well. The hardest and only class that I failed to finish was the simulation class. Every other class were simple fill ins for the initializes and other basic methods. The simulation class was the one that ran everything. importing each and every class into it, creating new instances of them and running them side by side. Coding it wouldn't have been so hard if I had more time, but I failed to manage my time properly and it came around and stabbed me in the back. I guess the most important lesson here is to start on my projects earlier next time.