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!

2 comments: