|
A & DS: Exercises from Friday
Exercise. Make a binary search tree node class.
public class BSTNode {
...
int key
BSTNode left;
BSTNode right;
...
}
Implement a BSTree class with insert and find
methods.
public class BSTree {
BSTNode root;
void insert(int k) { ... } // add a node with key k to the tree
boolean find(int k) { ... } // determine whether key k is in the tree
}
|