codeintuition-logo

Understanding recursive search


Searching for a value in a binary search tree can be implemented by piggybacking on any of the binary tree traversal algorithms. However, if we observe the special property of a binary search tree (given below), we can quickly develop an exponentially faster algorithm. 

  • All nodes in a node's `left` subtree are `less in value` than the node's value.
  • All nodes in a node's `right` subtree are `greater in value` than the node's value.

Algorithm

Liking the course? Check our discounted plans to continue learning.