This post is for the notes for me re-learning ‘binary search’, somehow I feel like I have been learned this algorithm couple times. But shame to say, I still do not feel I totally get the idea behind, as for how to implement this. I hope I can spend some quailty time for once again learn and master binary Tree.
The note here, and as code are from the GeeksforGeeksLink.
Binary Search Tree
**Binary Search Tree ** is a ‘node-based’ binary tree data structure which has the following properties.
The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.
Binary Search Tree| Set1(Search and Insertion)
Operations like search, minimum and maximum can be done fast.
Searching a key
If we had a sorted array we could performed a binary search.