Search in Binary Search Trees (Implementation)

This lesson is about Searching in a Binary Search Tree, and how to implement searching functionality in Java.

Introduction

In this lesson, we are going to implement the Search functionality by using the BST class. The following are the steps that we perform to search for an element in BST.

  1. Start from Root.
  2. If the value is less than the current node value, then traverse the left sub-tree; if it is more, then traverse the right sub-tree.
  3. Keep on doing the above step until you either find a node with that value or reach a leaf node—in which case the value doesn’t exist in the Binary Search Tree.

Iterative Search Implementation

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.