Thursday 31 October 2013

Binary Search Trees

This week, we were introduced to the binary search trees. We were already  familiar with trees, specially the binary trees. The extra feature of the binary search trees over normal binary trees is that they are, in a way, sorted. That is, the left sub-tree has lower and the right sub-tree has higher node values than the root node value.
Apart from that, we have started to learn the O( ) notation. It is way of  representing the time taken by the code, as proportional to some function of the input size.A binary search tree is helpful to a big extent when we are searching for presence of the given  items in trees. It reduces the time taken by our code to search for an element to O(log n) as compared to O(n)  for a normal binary tree, where 'n' is the size of the input.This happens because as soon as the item is compared to the root node value, we are able to figure out which side to look for.Hence after each comparison, nearly half of the tree is eliminated for a possible presence of the given item in it.
Other things going on are the weekly exercises and the assignment 2. The exercises have been easy to handle and were finished pretty quickly. The assignment is a bit tougher than the exercises, but a lot simpler than the previous one. Hope that things will fall in place before it's submission.
One more week and then we have the fall break. Term test 2 coming up after that. Will have to gear up for it!

Wednesday 23 October 2013

Linked lists

This week, we were given our marks for our mid term examination. Well, the exam was pretty easy, and I did receive a good grade in it. Happy, but not satisfied. Made a trivial error while passing the arguments in the second question.Will try to be more careful next time and not lose marks for the things I know. The new topic introduced this week was linked lists. They have some characteristics of lists as well as some of trees. Like lists, they store a data value, and like trees, they lead us to the next data member. Not that difficult to learn, once we understand the implementation of trees and the Node class from exercise 5. Attempted exercise 5 and got the (a) part at the first try. While implementing the (b) part, forgot to consider the case when the elements are "None", as wrote it in a hurry, at its preliminary stage. Don't know when I'll stop making these kind of errors. But corrected it as soon as I got some time to revisit it.Overall, learning is on the track and I'm enjoying it!!!

Sunday 13 October 2013

Recursion and Object Oriented Programming



This week was our first assignment submission. The assignment was quite challenging and also took a bit longer than expected. But it was fun. We worked in teams for the first time in this course. This helped me to make new friends as well as gain some teamwork skills. Other than that, all things are going pretty well. The exercises and labs are easy and interesting. They help us to keep a track of what we learn every week and ensure that we are able to implement those concepts properly. Another thing happening is the midterm, and thus will have to prepare for it also.

There are two topics that have to be discussed this week on the slog:

1) Recursion: Recursion is a process, in which a function is called inside its body,that is,while defining it. This allows us to break the problems into smaller,similar bits that are easier to solve, and then, their solutions can be applied to solve the larger and more complex cases. The most significant benefit of using it is reduction in redundancy of code. This not only helps to make the program shorter, but also reduces the time in writing as well as debugging it by us or anyone else. Moreover, the code sometimes becomes more efficient as well, like in the cases of nested lists and tree traversals.

2) Object Oriented Programming Object Oriented Programming is the method of programming that involves creating of classes that can instantiate objects, having some attributes and methods. The attributes can store some values related to the objects  and allow us to distinguish between objects of the same class by the difference in their attribute values. The methods are the behaviours of the object and allow us to do some tasks with it. The biggest advantage of Object Oriented programming is re-usability. The objects can used by anyone once they are created and one does not have to check for its proper implementation before using it. The encapsulation allows hiding certain parts of the objects, which prevents any undesirable tampering. Furthermore, the size of the code decreases as we don't need to write the functions every time we want to use them. This increases the efficiency and legibility of the code, and decreases the debugging time.