Tuesday, April 7, 2015

Impression of week 8 --- Binary Tree

This week is about Binary Tree. It is a special case of a normal tree data structure in which each node has at most two children, which are referred to as the left child and the right child. This adds some degree of certainty since each node only have two direction to branch out, either left or right. And this is where a special case of Binary Tree comes into play --- Binary Search Tree. 

BST is essentially a sorted BT in which for every node,  the right child will stores a value that is greater than its parent node, and similarly the left contains a smaller value than its parent.  The purpose for such kind of layout is to increase efficiency. For instance, from the labs, we are able to to search the BST very efficiently since we could avoid visiting unnecessary nodes. 

This week's lab provides a great chance practicing recursion, we call the function on each level of node where we are tackling the same scenario: taking an advantage of the attribute of BST, we could decide which way do we keep recursing.  





No comments:

Post a Comment