Could someone please tell me if this is the correct way to implement the search algorithm of the Binary Search Tree? (Using a standard Binary Search Tree)
abstract class BST {
public int data;
public BST left;
public BST right;
static public BST find(BST root, int value);
}
public class findBST extends BST {
static public BST find(BST root, int value)
{
if (root == null)
return null;
if (value < root)
return find(left, value);
else if (value > root)
return find(right, value);
else
return root;
}
}


Reply With Quote


Bookmarks