Project of DSA
Project of DSA
Group members:
Alishba Nadeem
BSAI-168
Ilsa javed
BSAI-200
Dure Adan Noor
BSAI-211
Presented to:
Ma’am Iqra
Question:
class BinarySearchTree {
class Node {
int key;
Node left, right;
Node(int key) {
this.key = key;
left = right = null;
}
}
if (root == null) {
root = new Node(key);
return root;
}
if (key < root.key)
root.left = insertRec(root.left, key);
else if (key > root.key)
root.right = insertRec(root.right, key);
return root;
}
if (root == null)
return false;
if (root.key == key)
return true;
System.out.println("\nIn-order Traversal:");
bst.inorder();
Output: