Saturday, April 4, 2015

My Final Impression And Overall Experience On CSC148

Well friends, time really does fly quickly. I feel like it was just yesterday when I stepped into my first lecture of CSC148 when we first started learning about objects. But all good things must come to an end, and it was the same case with CSC148. On the 2nd of April, we finished our final lecture, and we've got nothing more to learn from this course. So this will be my final slog for the course. As we all prepare for final exams, I'd like to reflect on the things I learned, some hurdles I faced along the way, and share my final impressions of the course.
First of all, I'd like to talk about a few things I along with my peers have learned in this course. I walked into this course expecting that it was going to be just like CSC108, where we learned about Python commands and executing them. I thought that it would be another technical programming course, but in the end, I was really wrong. I'm not saying there was no technical knowledge involved in this course. I did learn many interesting concepts like object oriented programming, abstract data types, recursion, tree data structure, linked lists and Big-Oh. But the big chunk of our learning experience for this course was actually thinking about and executing abstract programming. Throughout this course, we were taught how to create programs for abstract problems and make sure that they could be used by your peers and your clients as well. One example of this was in the beginning of the course, where we worked on the class Point, which deals with an abstract co-ordinate system. Not only did we use object oriented programming to create methods for the abstract co-ordinate system, but we also made sure that other people who'd like to import our program and clients who'd like to use our program could do so without directly copying and pasting the program. Besides abstract programming, another important thing we learned was how to make our programs shorter, more efficient and reader-friendly, since this is a really good skill to have especially when you enter the professional world. Something I really appreciate learning was list comprehension and ternary if, and it is because when you're programming at a complex level, these concepts can make your program shorter, neater and easier to understand. These are the things I've had the opportunity to learn in this course.
Now, regarding the difficulty of this course, it's definitely not been a walk in the park. I've really experienced a lot of difficulties in this course as well as CSC165, the other computer science course I'm doing. One of the key problems I've faced was actually implementing the concept of abstract programming onto a real world problem. So far, I'd only been used to specific problems which you can easily solve with the help of a few functions. But now, we were given an abstract problem, to which you had to find the solution by yourself. And it was really difficult, especially when it came to the assignments. Another hurdle I've had to overcome was recursion, and I had a hard time actually understanding it. As a result, I started struggling a bit with later concepts. However, I soon buckled up and realized that I had to learn it soon, so after immense dedication and concentration, I was able to understand the concept of recursion far more better than I used to before. I'd like to take this time to thank my instructors, TAs and my peers who've always helped me learn new things and helped me in my time of need.
I guess this is pretty much it for me in this course. In conclusion, I've had a blast with this course. It certainly was challenging, but it's all been worth it in the end. This course has really motivated me to learn a lot more about the science of computing, and I'm really looking forward to learning it in the future years to come. Well, this is it for my adventure in CSC148. Good luck to all for the years to come, stay awesome and keep coding. Goodbye.

Saturday, March 28, 2015

Reflections on blog about tracing recursion

On the 5th week of CSC148, I wrote a blog about my impressions and my experience regarding tracing recursion. For this week's blog, I will provide my thoughts on how my impression of recursion changed as we went on with the course. I will also compare my experience in this topic with that of my classmates and my friends.
When we were first introduced to recursion, the concept of it simply befuddled my mind. I had no idea about what it was, how it worked and how important it was in the field of computing. Just to refresh your mind, recursion is when you call a function within the same function. Pretty strange, isn't it? That's exactly what I thought. So at time, I vowed to myself that I'll simply learn how to trace recursive code in order to succeed in the exam and from then onward, I'll never even come near this topic again. I had a similar conversation with my friends and out of frustration regarding not being able to understand recursion properly, we all agreed. I simply thought that recursion is one of the many programming techniques we'll learn and that there are many more (possibly easier) solutions to it. I underestimated its importance but friends, I could not have been more wrong.
Starting from week 6, we started learning about tree data structures. I was excited about learning a new concept, but what really surprised me was the amount of recursion involved in each and every function. When we created the tree class, everything from small functions such as repr, str to functions that show whether a number is present in any node of the tree or not, recursion was there. Furthermore, we moved on from simply tracing recursive functions and code to writing our own recursive functions. Personally, it was a difficult experience for me since it was a whole new leap from the work that we previously used to do. However, after hours of dedication and concentration, I started getting the hang of writing recursive code. I went on and did more research on tree data structures, when I came to realize that it had vast applications in may fields, especially in the field of artificial intelligence. Since it is the field of my interest, I had to understand the fact that understanding recursion and writing recursive code is mandatory for me.
Furthermore, for our second assignment, we had to implement a strategy called minimax in a game of tippy where the computer selects the best possible output given the game state and the circumstances. When I started to work on the program, I realized that the only way to solve this problem in a short and efficient way was by using recursion. Now I'm not saying that recursion can't be substituted. Functions that are made easier with recursion can also be done manually. However, the program would be extremely long, messy and hard to understand for yourself and your peers. That's something you wouldn't want if you want to succeed in programming in the future. Since I was working alone, I couldn't discuss with my partners regarding the assignment. But after the due date, I had a discussion about it with my friends and we all came to a unanimous agreement that we had underestimated the importance of recursion in the field of computer science. 
Now, my opinion of recursion have completely changed. I've realized that by substituting manual code with recursive code, you make the function shorter, more efficient and less likely to produce errors. Now at this stage, whenever I encounter a problem in programming, I try to see if I can solve the problem using recursion. I know that for those new to recursion, it is a difficult concept for many of us, but I can't stress how important it is to everybody and the only way to succeed in it is by practicing a lot. If you encounter problems, don't forget to ask for help when it is all around you. Finally, to understand more about recursion and how to trace them, you can check out the link http://looralicsc148.blogspot.ca/2015/02/week-5-tracing-recursions.html. Here, the person has given a detailed explanation on tracing recursion. Well, that's pretty much it for this blog. I hope you'll find it informative. I'll see you all next time. Until then, stay awesome and keep coding. Bye.

Saturday, March 21, 2015

Learning a new programming language

Hello everybody.
For this week's blog, I wanted to talk about why it is necessary for everyone to learn programming in any programming language. This might be helpful to those who've been having thoughts in their head that are telling them to learn coding. This might also be helpful who're already proficient in a programming language, but are too lazy or doubtful about learning a new programming language.

First of all, I think it is important to learn a new programming language so that it serves as a platform for actually learning some of the techniques we learn in computer science. We need programming languages in order to apply our knowledge in computing and make interesting things happen. For example, this semester, we've learned a whole lot about recursion. We can trace recursion in our minds and on our notebook, but to actually apply it and to truly understand what's happening, we need to code it in a programming language. Not just in our course, but the need to learn a programming language also becomes handy in our daily lives. For example, we can come up with the idea of a program through which we can create a proper budget for our income and gives us a detailed report of our expenses. However, one needs knowledge of using a programming language in order to actually make that idea a reality.

Secondly, I think that it is really important to learn a programming language since it makes the process of learning other programming languages a lot more easier. For example, I've recently started learning C++ after Python and I must say that now, the process seems a lot more easier. And the reason for that is quite simple. It is that programming and computer science aren't the same thing. Computer science deals with computing techniques and the use of computers in solving problems, whereas programming is the process of applying that knowledge in a programming language. When you start programming in a new language, you're essentially applying your knowledge onto a programming language through code and observing the output. Since you get a lot of experience with applying computing techniques through this process, doing it again in a brand new programming language becomes no challenging task. The only challenge then would be adjusting to the change in the code command.

Lastly, I think that learning to code in a programming language is really necessary since it serves as a major skill in your resume when you're heading to the workforce or to graduate school. Nowadays, the presence of computing and software in any profession is undeniable. In this case, having knowledge of programming and understanding software and programs really puts you ahead in the workforce and opens up a lot of unimaginable opportunities for you. Furthermore, learning programming also develops your logic and problem solving skills which is greatly appreciated by employers and everyone wherever you go.

Well that's pretty much it from what I think. I hope that was able to persuade you to learn a new programming language. If not, I hope this will make you appreciate programmers even more and keep the thought of making taking up a book and learning a new programming language in the back of your minds. I guess it's time for me to take my leave. See you all next week. Till then, stay awesome and keep coding. Bye.

Saturday, March 14, 2015

Becoming a successful programmer

This week in CSC148, there wasn't anything that grand or special. We only had 1 week of class where we learned about inserting or deleting nodes from binary search trees. To learn more about trees, you can refer to my previous blog where I've talked a lot about trees. Anyways, for this week's blog, I wanted to talk about something else besides stuff we learn in this course. I wanted to talk about something that's always been on my mind, and that is how I can become a good and a successful programmer. Well I'm not implying that I'm the best programmer in the universe. I know I'm nowhere near that level of expertise. But I'd definitely like to be a good one and I know that you all reading desire the same as well. So I wanted to share a few steps which me myself and everyone else can apply to their daily lives to be better programmers.

I think the first and the most crucial step towards becoming a good programmer is practice. We've all heard the quote that "practice makes perfect" and that definitely applies to the field of programming. What separates a good programmer from normal programmer is the amount of time besides schoolwork dedicated towards learning new programming languages, more efficient programming techniques and advanced concepts in computer science. Practice will definitely keep you ahead of the curve. Alongside that, practicing in your own time also raises a lot of questions in your mind for which you can seek the help of professors and TAs. By doing this, you're also making good connections with experts of their own respective fields which could open up a lot of doors for you in the future.

Secondly, I think another very important step towards being a good programmer is innovation. Simply learning new stuff sounds really exciting, but that's barely scratching the surface in terms of being a good programmer. I think that one needs to be innovative, and create his/her own creative projects. Based on your level of expertise, it doesn't hurt to come up with simple software or programs. There are lots of advantages to this. First of all, it helps you understand your strengths and weaknesses when it comes to programming. You can improve your weaknesses and further strengthen your positive aspects. Secondly, you can represent these projects of yours in order to display your programming expertise and experience, which can be really useful to you when it comes to entering the job market or grad school in the future. Lastly, by doing these projects, you get the opportunity to explore which area of programming you like more and which one you like less. This will really help you plan for the future. And who knows, maybe you'll create the next breakthrough program that can make a billionaire. But lets leave that aside for the future.

The last but not least important step towards being a good programmer is discipline. I see that there's a heavy sense of procrastination in the field of programming. A lot of times, people say that they'll learn more the next day. Or sometimes if people encounter an error when working on a project and can't find the solution, they get easily pissed and just give up halfway. Sometimes people get awesome and innovative ideas, but they're too lazy to even bother beginning. This is a huge problem since this'll only hold you back from releasing your full talent. That's why I strongly advise you to stay in discipline and manage your time properly. If you encounter errors, you must persevere and try your best to come up with a solution. If not, you must search for help. If you want to get started on a project, you must start managing your time properly, so that you can stop wasting your time procrastinating and start working on your project. Remember, time is limited and it's very hard to find time for anything once you reach adulthood. So make wise use of it.

With this, I'll be ending my blog. I hope you found this information useful. I'll see you all next week. Till then, stay awesome and keep coding. Peace out.

Saturday, March 7, 2015

Understanding Tree Data Structures

As we continue learning more about abstract data types, or ADTs, we were introduced about a brand new ADT called trees. It was a very difficult data structure to understand at the first try for me since there were a lot of new terminologies and techniques that I did not understand, but now that I think I more or less got the hang of it, I thought I'd give my two cents regarding this topic. I'd start with a brief introduction of what trees are and some of the terminologies behind it. Then, I'll talk about some actions that you can carry out with the tree data structure. Lastly, I'll also talk about binary trees and binary search trees.

Now, first of all, we can confirm that trees are an abstract data type because just like any other ADT, we specify the kind and meaning behind the data type we store, and various methods we can carry out on that data type in a tree. The way a tree works is that there is a parent node, which may or may not contain data, that is connected to one or more child nodes, or children through edges. All trees begin from a single node, which we call the root. The interesting thing about trees is that except for the root, all nodes have exactly one parent. We also have paths in a tree, which is basically a sequence of nodes from one node to another. In order for paths to exist, all consecutive nodes from the beginning node to the end node must have an edge connecting them. The number of edges in a path are what we called the length of the path. Since we know that all nodes except the root have exactly one parent, we can conclude that all nodes have exactly one path to its parent node as well as the root. Another interesting thing about trees is that it flows continuously from the root to the leaf (a node with no children), thus avoiding any possibilities of loops in a tree. If you want to find the height of a tree, you can do it by adding 1 to the length of the entire tree. Easy, isn't it? The last important terminology would be the arity, or the branching factor of the tree, which basically refers to the number of maximum number of children for any node.

There are lots of interesting functions and methods that we can carry out using the tree data structure. However, dealing with this data structure requires a solid grasp of recursion, so learning this topic is mandatory. First and foremost, we can carry out the basic methods like __repr__, __str__ and __eq__. As we can see, in the  __repr__ and  __str__ function, once we carry out the operation for the parent node, we call the same function again for the upcoming children node, which have their children node. Yeah, I think we know it now. By calling the function again within the same function, we are applying recursion. Sweet. We can also carry out operations like finding the height of the tree, and check to see if a certain value is present in any possible node of the tree or not, though it requires a strong understanding of recursion just like the other functions. One can also carry out traversal, which simply means visiting the nodes in order to carry out certain operations or functions in them. There are three types of traversals. They are:
i) in-order traversal: visiting a node between its children. Note that this is only applicable for trees that only have two children.
ii) pre-order traversal: visiting a node before its children.
iii) post-order traversal: visiting a node after its children.
Of course, one can also be creative and come up with many other unique operations and functions for trees.

Now I'd like to take a moment and talk about binary trees and binary search trees. A binary tree is a tree with the additional property that it has an arity of 2. In simple words, any node in a binary tree can have an utmost of two children, where the children in the left is called the left child, and the children on the right are called right child. A binary search tree is just a binary tree with the additional property that the value for every node is greater than all values of nodes in the left sub-tree and smaller than all values of nodes in the right sub-tree. This property of a binary search tree makes searching for values faster and more efficient since now, we can filter out a large chunk of values without having to go through each and every unimportant data individually.

Trees are a very important way of storing data and they can be used to represent sorted data, make data more easily searchable, and make the process of searching data faster and more efficient. I'm really interested in learning more about this data structure and I'm looking forward towards learning more. This is it for me today. See you guys later. Till then, stay awesome and keep coding.

Saturday, February 28, 2015

Summary On Abstract Data Types

One of the main objectives of a programmer is to create programs and code which is efficient, elegant and properly readable by the programmer him/herself, his/her colleagues and the clients. For this, one has to focus more on the semantics of the program than on its implementation, which he/she does by creating classes for a certain data type and by defining various methods that could be carried out on the data type. This is where abstract data type comes in really handy.

An abstract data type (ADT) is a data type where we specify the kind and meaning behind the data type we store, and various methods we can carry out on that data type. I can see three major advantages to using an ADT to solve problems in computing than the normal ways in which we solved things back in CSC108. They are:
i) Using the concept of ADT definitely makes the program look a lot more elegant and readable for    yourself, your peers and your clients.
ii) Since you don't have to focus on how the program is implemented, there is a lot more freedom in thinking about algorithms or new methods for the program.
iii) Lastly, through the use of ADT, one can easily carry out tasks like debugging, maintenance, updating the program, etc. in an efficient and organized manner, without disrupting the client code.

There are two main examples of ADTs that I would like to talk about. They are Stack and Queue. They are both similar in the sense that they are both implemented as a list in Python in order to pile up objects and remove them. However, the way they add and remove objects are different, and that's what I will be covering. 

Stack:
A Stack is a linear sequence of data types. In a Stack, new items are stored on the top (end of the list), and items at the top are the ones that are removed first. Think of it as a stack of new notebooks when you go to to the shop. Usually, shopkeepers add new notebooks to the top of the stack, and consumers take notebooks that are on the top of the stack. 
Some operations that can be carried out on the Stack ADT are:
i) Reverse the sequence of the Stack.
ii) Pop: Remove and return top item, provided the stack is non-empty.
iii) Push(item): Store item on top of stack.
iv) is_empty(): Return whether the stack is empty or not.

Queue:
Just like Stack, A Queue is also a linear sequence of data types. However, new items are stored at the back of the queue (end of the list) and items at the front (beginning of the list) are removed first. This means that in order to remove an item you just added in a queue, you need to remove everything you added before it. 
Some operations that can be carried out on the Queue ADT are:
i) enqueue(A): add object A at the back of the queue (end of the list).
ii) dequeue(A): remove and return object A from the front of the queue(beginning of the list).
iii) Reverse the sequence of the Queue.
iv) is_empty(): Return whether the Queue is empty or not.

I'd recommend checking out the week 5 blog in the link http://nigerianmahogany.blogspot.ca/. Here, the person has a visual representation of what happens in a stack and in a queue.

And that's about all I have regarding ADTs. I'm really enthusiastic towards learning about more ADTs, and I'll update you all if I learn more. Any questions are welcome and you can leave them in the comments below. Till then, keep on coding and stay awesome. Bye.

Saturday, February 14, 2015

My Summary Of Object Oriented Programming Concepts

So far in CSC148, we've been practicing object oriented programming (OOP) in Python, and although there's much more for us to learn regarding object oriented programming, I wanted to briefly summarize and explain some of the concepts we've learned so far in this field, and that's what today's blog is going to be all about. First of all, I'm going to give a brief introduction to object oriented programming and explain what exactly it means. Then I'll start explaining the concepts in OOP I've learned so far.

Ptting it in simple words, OOP (Object Oriented Programming) is a way of programming in which the user not only defines the data and its type, but also functions and methods that can be applied to it. This way of programming comes very handy especially when it  comes to abstract programming. For example, in our first week in CSC148, we made a class called Point where we create various methods and carry out various operations, based on an abstract set of co-ordinates given by the user.

Now, I will start explaining some concepts that I learned in object oriented programming.

1) Objects:

In OOP, we bundle up the data type and the methods applied to a data structure and call them objects, which are stored at a location in memory. In Python, every single thing from integers, strings to even classes, are objects. One of the advantages to this type of programming is the ability to import modules like math, str, unittest, etc., which make programming a lot more easier since instead of carrying out various operations on your own, you could already use pre-defined functions in a module.

2) Classes:


In simple terms, one can think of classes as a template or a backbone for creating objects, initializing variables and creating as well as implementing various methods. In out first week, in order to solve the abstract problem which I talked about in my explanation of object oriented programming, we created a class called Point where we initialized a variable name for the co-ordinates and started creating and carrying out functions like finding the co-ordinate's distance from the origin.

3) Inheritance:

I guess one of the cool things I've liked about Python so far is how you can create a new class that inherits objects and methods from the old class, thus making programming a lot more easier and elegant. This is what we call inheritance. In CSC148, we practiced inheritance by creating a class called employee which takes in details of an employee and returns their amount of pay and total pay. After that, we created subclasses called HourlyEmployee and SalariedEmployee which inherits methods from the employee class. This made the programming process, especially the process of initializing variables a  lot more easier since by inheriting the init function, one can avoid writing the same code over and over again which takes in a lot more time. This feature is especially important in cases where one has to create many different subclasses but carry out similar methods as in the parent class.

For further information regarding OOP, you can also refer to the link of one of my peers, which is https://humaircsc148slog.wordpress.com/2015/02/15/object-oriented-summary/.

And that's about what I've learned regarding object oriented programming that I can write off the top of my head. I know for sure that there's a lot more to learn regarding this way of programming and I look forward to it. Until then, keep coding and stay awesome.