Week 7 was all about Trees specifically Binary Trees and Binary Search Trees(BST). I really enjoyed learning about Binary Search Trees because the fashion in which they are designed made searching simpler and better than linear searching. I was initially confused why is the height to be searched in a BST proportional to log2(N) where N is the number of the nodes but I was clear with it when I drew pictures for trees of different heights and searched for elements at different levels.
This Tree diagram represents a Binary Tree where each node has two children. This resemblance with family relations helps me understand the concept of trees better.
This tree is a BST where all the left children are less than the root and right children are greater than the root. This is a special property of BST which distinguishes them from Binary Trees.
Writing Binary tree functions we had to take special care of None which was to be one of the base cases. There was no None in n-dimensional trees because the children were stored in a list so they either had something or were empty. So dealing with None data type was one of the things which I became confident this week and it was mainly with practising lab exercises which were pretty challenging. Taking inspiration from other slogger's blog I thought of sharing my solutions to the lab's which can be found here. I am doing this to help people struggling on labs and also to get feedback from other sloggers about my solutions.
I also misunderstood Minimax where I thought I had to built Trees but later realized that we didn't have to use Trees at all instead had to use Recursion which recursively built Trees.
No comments:
Post a Comment