Monday, 30 March 2015

That's All Folks !!!

Here we are, to the end of semester.. wow that went by wayy too quick.
.
.
.
.
Pfffftttt who am I kidding, I can't wait for finals to be over and summer to start.

I feel like I should have some really significant advise to give people who might be taking this course in the future or even someone who's reading this right now in preparation for finals advise, but honestly all I can think is 'you learn from your mistakes'.
I don't think one can learn something completely based of someone else' experience neither is there some great advise that we as students are unaware of.
It all comes down to your natural ability to code and how much you practice.
Practice seems wayy to obvious an advise to give but I think its the best. Coding isn't like biology where naming the process is super important. We have to completely understand it's working, and only then can we actually use it. Now if you're thinking practicing is the same as memorising then you're wrong. When I mean practise, I don't mean, doing the same kind of problem for different objects. No. The entire process has to be different, only then can you know if you understand the concept completely and can use it for any given condition or problem.

I feel like I should talk about assignment 3 just so I have a mental closure of completing the slog for this course. Assignment 3 wasn't exactly easy per se, but it was easy compared to assignment 2. It also made things easier for people working in groups as we all could work on it separately without needing to constantly discuss ideas. I'm fairly certain my partners and I did well and like I mentioned a few posts ago, I'm hoping for a 100.

Looking back on this course, I have to say I found things more interesting than I found them difficult, or maybe they go hand in hand (at least for me! ). They more complex things got, the easier it was for me to focus completely on this course without neglecting it.
Certain 'hurdles' I had to cross can be summarized by one word, 'recursion'. But then again this entire course was mainly about it so I wouldn't want to call the entire course a hurdle.
The thing about recursion is, it's easy to get confused and that makes me lose my patience with it. So I guess the real hurdle was my impatience.
Another hurdle that I just realized I had to cross was time management. Being in 1st year, a lot of my other courses are for my breadth requirement and it's convenient to focus only on them or my CS course. But in the last few weeks, I have learnt time-management is one skill you are never too old to have.

So thats all people, hope everyone does great in A3 and finals.

I would like to thank Diane and will miss her, and her creative approach to lessons. I found them extremely fascinating and made bunking class a lot harder.
I would also like to thank all my friends in this course for keeping me sane and constantly motivating me (especially to do slogs! ) and helping me when I lost patience with recursion.

Can't say 'until next time..' so GOOD BYE !

PS - *tears of joy roll down my face as I move my cursor towards 'publish'.* YAY for everyone in this course, for surviving through the strike and once again good luck to all for finals !



Tuesday, 24 March 2015

A Walk To Remember...

SECOND LAST POST YA'LL ! *woot woot*

So we're almost there, I can feel the tension building up, and the caffeinated spirits seem to be on an all time high.
 The best part about slogs is that we can not only see ourselves growing in understanding through the semester but also our friends and classmates. I can definitely look back on this semester and CSC148 and say I've made some really good friends out of it and learnt something interesting. 

Keeping the title in mind, I'd like to revisit my post "More Recursion !" (it can be found here, http://mysuperslog148.blogspot.ca/2015/03/more-recursion.html ). You'd think I'd want to go back to the very beginning of semester or maybe even the beginning of the topic recursion, however I'd like to visit this particular post because while in my original recursion related post I only explained the theory behind it, here I gave an example. Now the thing about recursion is, the deeper you go, the more complex it can get, and sometimes its a simple factorial recursion code that you need to bring you back to the basics. Its easy to get deep into recursion and forget what its supposed to do or where it returns what. Though I try to keep in mind the "keep it simple" advise Diane gave us, it's still easy to forget when I'm knee deep in something like MiniMax. (ugh ugh ugh)

Since I mentioned making friends this semester, let's see what some of them have to say .. 

Cindy Quach ( my assignment partner for the whole semester ) has an interesting approach towards coding. Putting it simply, she needs good sleep and good food and bam! she's good to go. She is really fun to work with because she gets really motivated and determined to finish things off quickly.
One of her posts ( http://csc148x.blogspot.ca/2015/03/recursion.html ) shows her approach quite nicely. She believes in understanding the concepts extremely clearly and reading and analyzing each line. Here, she uses a simple example to explain recursion very accurately. 

Syeda Sidra Tul-Muntah  is another friend I've made through our common lab. She and I share a similar approach to understanding coding. Her slogs are always up to date and quite detailed. You can check them out at http://slogsbysidra.blogspot.ca/ .

So basically everyone seems to have learnt from each others' point of views, and we all seem to agree on how much we have loved this course. 

Until next time.. !

PS- That title though .. I hope people know the reference. 

PPS - Really random but all I can think of right now is the song from High School Musical 2.. summer..summer ..summer.. 

Saturday, 14 March 2015

Creeping on to the final weeks....

First things first, the test.
.
.
.
.
Honestly I'm pretty sure I bombed it. Did not expect that. I somehow forgot the basic of traversing but managed to get it right, but in the process managed to blank out on everything else. I'm really disappointed because I expected this test to go as awesomely as the first. What makes it worse is that I was highly confident about the topics on this test. Trees, BST and Linked list all seem to me like something I understand pretty well.
Maybe I underestimated it ?
Anyhow, I'm now determined to get a 100 on both assignment 3 and the final.
(Someone give me a HELL YEAH ! )

Moving on to things we learnt..

We pretty much discussed only assignment 2 and how the profs wanted us to work it. They've given us the unittests that we need to make it run. I don't remember if I mentioned this in my other posts but A2 was surprisingly annoying and I didn't do my best. (Thus my determination for A3 and final)

With this course coming to an end in a couple of weeks, all I can say is how much I appreciate the marking scheme and the planning of this course.
I'm pretty sure it's considerably different from last few years and its only for the better.

Not much to say right now except I hope the test is marked easy .. :P

Until next time ..

PS - tick tock tick tock ..end of semester came up too fast !

Tuesday, 10 March 2015

Linking Stuff...

Linked Lists !!!
I probably sound too enthusiastic but familiar terms make me happy :)

So linked lists is again something I've briefly done in high school and since its the same concept, I had a much easier time understanding.

Linked lists are basically linear sequence of nodes with a reference to the front or the head.

Linked List 

The key to understanding and doing well in linked lists is drawing it out. There's no better method. The front node here is the box with 2 and 2184 and the back node is the box with 7 and Null.
It is Null here since there is no next node to keep a reference to. The most important thing in linked lists is to know which nodes we have to keep track of. Insertion, deletion etc of nodes can get quite messy if we lose track of the nodes. This is where drawing comes in, it allows us to physically see which node needs to be connected to which other node. 

The labs for linked lists are pretty straightforward and I'm hoping to do well in linked lists related questions on the test tomorrow.

Speaking of.. test 2 ! 
With the strike in full force I'm kind of confused about how they'll mark us or if they even will. I'm hoping the strike is resolved soon with both the parties happy. I have to say not being able to actually go to labs is a bit of an inconvenience especially since our new TA seemed really helpful.

I'm all set for the test and honestly this slog was mostly just to take a break from the actual coding. 
I've discovered that I find it more helpful when I write the code down now since I've realized that it affects my performance. Depending too heavily on running the code on Wing makes me less intuitive about the logical as well as syntax errors I could be making. 

Until next time .. ! 

PS- Goodluck everyone ! :) 

Friday, 6 March 2015

All About The Trees..!

Trees.
To normal people outside of the world of CS, this word might seem completely harmless. Might even give them happy thoughts, trees..greenery .. who doesn't like that, right ? right ?

Wrong.
Because to programmers, it is like a mini nightmare in one word.
But no, don't be afraid because it's not all bad... at least not yet.
Let me tell you why...

So, like I explained in my previous post, recursion is a simple concept to understand and trace but not that easy to code. There's is a general idea to follow but unless you understand exactly how to you want your code to work, recursion won't seem like the best idea.

"A tree is a set of nodes with directed edges between some pair of nodes." These edges connect a parent node to a child node.
A specific type of tree is Binary Tree. In this type of tree each parent only has two children, the left and right. This makes navigating through the tree a little easier.
This week we learnt to traverse through a tree in order to find its height and to find if a value exists in the tree or not.
Another specific tree is the Binary Search Tree. Like it's name suggests, you search for something in a tree. The catch you ask ?
BST (we love abbreviations), has to be made in a specific order. While these specifications might make the task easier, it is slightly confusing to understand.


Binary Search Tree

This is an example to understand how the placing of numbers in a BST works.
Each node on the left has to be smaller than all the nodes on its right. As you can see, 
9 < 12<14 < 17<19 < 23.....<76.
In this way, searching for a number becomes increasingly simplified. 

As far as I understand, trees work in a certain way, which is the key to coding with recursion for trees. 

Until next time.. !

PS - Did anyone get the song reference ? *no treble*



Sunday, 1 March 2015

More Recursion !

Hey everyone, (everyone who's reading this at least)

I hope your reading week was fun, relaxing and as unproductive as mine. I think the only thing I worked on is assignment 2 with my partner Cindy (http://csc148x.blogspot.ca/ ).

Since recursion is part of the assignment this time, it only makes sense that I write about it.
 In my previous post from February 6, I mentioned what recursion is and how it is supposed to work.

In assignment 2, we use a MiniMax which is a strategy generally used to two-player games where the best possible move is chosen by both players. For this particular we need to use recursion.
Since we're not allowed to give out assignment details, I'll try to explain it as simply as possible.
Recursion calls on itself again and again till it reaches the base case or the stopping case, and in the case of Minimax, both players need to have complete knowledge of the game.
For Minimax to work, we use recursion to find out what each move will lead to and will that move end in a win or loss. So we call on our method again and again until it reaches the end of the game for each move available in that game state.

To illustrate how recursion works, I'm going to show a simple example. A simple thing to remember is that recursion works in place of iterative functions.

*****************************
def factorial (n):
    """ (int) -> int

    Return factorial of n.

    >>> factorial (4)
    24
    >>> factorial (12)
    479001600
    """
    if n == 1 :
        return 1
    else :
        return n * factorial (n-1)

*****************************

In the example, "if n == 1 " plays the role of the stopping case or base case. Once it reaches here, the recursion process stops and the values start getting returned.
When n == 4, the else condition is executed and thus factorial calls itself but this time n = 3.
This continues until n = 1 and so the value 24 is returned to the user.

While recursion as a concept is easy to understand, and even easy to trace, it isn't however easy to write.
The assignment is giving us a little bit of trouble at exactly this and we hope to figure it out soon.

Hope this made sense!

Until next time ...

PS - I hope I'm not the only one not getting this part of the assignment ! Good luck to everyone ! :)



Friday, 20 February 2015

Object-Oriented Programming !

So to start off I'd like to say, I initially thought I was writing too much and then did some checking and found out people have been writing far more than I have and far more intensely. Oops ?
Anyway, quality over quantity and all that so I'm going to continue my own thing.
Another thing I'd like to mention is how awesome were the midterm grades ???? I hope everyone did well on it and isn't mad at me for being all cheery about it !
Moving on ..

OOP !
I kind of feel a little silly writing this because let's face it if anyone wanted the definition they'd google it not look at my blog but anyway  Object-Oriented Programming makes use of several concepts all inter connected that we've been using so far in csc148 and even csc108. It revolves around the concept of Abstract Data Type and some of the important terms that one comes across in OOP are object, class, attributes, methods, and inheritance. 
Objects are data structures that contain data and can be assigned to a variable name.
Classes are basically the structure or blueprint or the base of the your program. It is used to perform actions using its methods and attributes,in a cleaner and consistent manner. For creating objects within a class we use the syntax :

                 post = blog(4 , '20th Feb 2015')

Here, 'post' is the variable used for the object,
          'blog' is the name of the class,
          '4' and  '20th Feb 2015' are both attributes 

Inheritance, like its name suggests allows one class, the subclass, to inherit the methods and attributes of another class, the parent class. This is done to avoid redundant and duplication of code. Simply put if there is one class that has methods and attributes in common with a few other classes, it would be more simpler to write that code only once and let it be inherited by the other classes.
For example :

class Worker:
    def update_salary(self, salary):
        self.total_salary = self.total_salary + salary

class HourlyWorker(Worker):
    def calc_wage(self, num_hours):
        self.wage = num_hours * 11.5

class SalaryWorker(Worker):
    def calc_salary(self, commission):
        self.salary = self.salary + (10/100)*self.salary

Here, 'Worker' is the parent class,
          'HourlyWorker' and 'SalaryWorker' are both the subclasses 
          'update_salary' , 'calc_wage' and 'calc_salary' are methods 

Both kind of workers would need their total salaries updated and so that method stays in the Parent class, however the way of calculating said salary is different and so it would be done in separate classes.
The example also shows the syntax that we use to execute inheritance.

So I hope this was simple enough to understand. I didn't try to paste actual code because I'd rather type it out here fast so I hope that didn't bother anyone.

Until next time then..

PS- Doing this during reading week took lots of coffee and a lot of motivation by my friends.
PPS - Is anyone reading this ? ...

xx