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.