Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Retrieve a value associated with a given key */
- public Value get(Key key) {
- Node<Key, Value> x = root; // 1
- while (x != null) { // 2
- int cmp = key.compareTo(x.key); // 3
- if (cmp < 0) { // 4
- x = x.left; // 4
- } else if (cmp > 0) { // 5
- x = x.right; // 5
- } else { // 6
- return x.value; // 6
- }
- }
- return null; // 7
- }
Advertisement
Add Comment
Please, Sign In to add comment