Friday, 28 March 2014

Binary Search Tree

Binary Search Trees are an implementation of LinkedList. 

We have seen implementation of List representation of trees. Much like LinkedList, they contain a node which has a root(contains information) and then a self.left which represents the left branch of the tree and self.right which represents the right branch of the tree. 

Ex// 
Tree[3, Tree[5,Tree[6, None,None], None], Tree[8,None, None]]

                                                  3
                                               /     \        
                                             5        8
                                           /   
                                         6      


The implementation of a binary search tree is very similar in its implementation. The requirements of a binary search tree are that there are no repeating node values and any values which are less than the root go to the left branch and a node with a value greater than the root must go to the right branch. This repeats for each subtree. 




No comments:

Post a Comment