Tuesday, February 18, 2014

Recursion..!!


The most important thing so far in this course has been recursion. The simplest way I can think of explaining recursion is that it is the process in which a function calls itself again and again. The basic idea is to break the problem into a smaller multiple, device a solution to it, and use this solution to solve the bigger problem. It makes the more complex problems rather easier. It is definitely not the easiest thing to get hold of, but really helps to solve the problem in a short and easy manner. I took some time to get the slightest hint about this, but after doing the Assignment, I feel comfortable using it.

I feel the key here is to think of what happens in the simplest case, and work the function around that. Doing this is not at all easy, but once we get hold of it, things become easy. The applications of Recursion are immense, and can be used in most of the programming languages. It definitely makes the programmers life easier (only once you know what it is, but until then it is a nightmare).  

Week 6

This week we learnt about a new ADT, Trees. I did have some basic idea about how they work, but it is the first time I am learning to implement it. The thing I liked the most was the way my proff explained the different ways of tree transversal. I was able to understand the thing in my first attempt and I feel comfortable with the material covered so far.

Week 5

This week we talked about the haunting Assignment and Scopes. I have learnt C++ before and I was clear about scopes. Knowing the scopes of your variables in your program is very important, especially in languages like C++ and Java. The new thing I learnt this week was how to use variables with same names, one defined locally and other globally using the ‘nonlocal’ and ‘global’ keywords. I haven’t come across any of its application until now, but I feel it would be important in the future.

The Assignment was much harder than the once we had in CSC108. It was really fun doing the assignment. The most challenging part, I think was completing Tour.py. It also helped me strengthen my understanding of recursion. The biggest thing I learnt from this assignment was to always read the handout very carefully, because I only skimmed through it and has to do a lot of unnecessary extra work.


Week 4

This week we mainly learnt about recursion and list comprehensions. I personally liked list comprehensions and found them little challenging. I thought they were a little to understand at first, but gradually I got hold of them. They make the code look much more clear, shorter and concise.


The other thing was one of the most important topics of this course and programming – Recursion. It is to solve the problem by breaking it into smaller problem and using the solution of the smaller problem to solve the bigger problem. I felt it to be really tricky, every time I thought I got hold of it, but the next example left me with loads of confusions. Now I think I understand it (hopefully). The thing that helped me the most in understanding it was going through the definition of recursion again and again. Just solve a smaller multiple of the problem and call it again to solve the rest of the problem..!! 

Thursday, February 6, 2014

Object Oriented Programming


‘Object-oriented programming is a programming paradigm that represents concepts as "objects" that have data fields and associated procedures known as methods.’ It means to represent the problem on hand in objects. These objects have properties (variables) and methods (functions). The biggest advantage of this, in my view, is that it becomes very easy to relate the program to the ‘real’ thing.

Let’s consider the example of a vehicle. It would have wheels, a fuel tank, would be able to move, etc. Writing this in a program without OOP would be hard. But using this technique, we can easily write a class with wheels, etc. as variables and functions for everything it does.


An important feature of OOP talked about in the class was of Inheritance. It simply means that we can use the same code in a different program without having to actually copy-paste it. Its biggest advantage, for me, is not to write the same piece of code again, we are able to use the same debugged code. There is always a possibility, even for the best of the programmers, to make a small mistake in the program that he has previously written (maybe of a semicolon which is very frustrating). Using inheritance, we can easily avoid this. Other advantages include stuff like not having to make changes everywhere when adding a feature to the code, or saving the labour of writing it again.