August 2024
Intermediate to advanced
516 pages
11h 47m
English
These are the solutions to the exercises found in the section Exercises.
The tree should look like this. Note that it’s not well balanced, as the root node only has a right subtree and no left one:

Search within a balanced binary search tree takes a maximum of about log(N) steps. So, if N is 1,000, search should take a maximum of about 10 steps.
The greatest value within a binary search tree will always be the bottom rightmost node. We can find it by recursively following each node’s right child until we hit the bottom:
| | function max(node) { |
| | if (node.rightChild) { |
| | return max(node.rightChild); |
| | } else { |
| | return node.value; ... |
Read now
Unlock full access