29/03/2016 – Data Structure

Binary Search Tree

BST has 3 basic operations

  • find (x)
  • insert (x)
  • remove (x)

Property of BST makes searching easy.

If we’re trying to find(x), we begin with these steps:

  1. We start at root
  2. If root contains x, search is successful
  3. If x<root, search is done on left, if x>root, search is done on the right side.
  4. Search is repeated and done recursively

Example of a tree: