Exercises
The following exercises provide you with the opportunity to practice with binary search trees. The solutions to these exercises are found in the section Chapter 15.
-
Imagine you were to take an empty binary search tree and insert the following sequence of numbers in this order: [1, 5, 9, 2, 4, 10, 6, 3, 8].
Draw a diagram showing what the binary search tree would look like. Remember, the numbers are being inserted in the order presented here.
-
If a well-balanced binary search tree contains 1,000 values, what is the maximum number of steps it would take to search for a value within it?
-
Write an algorithm that finds the greatest value within a binary search tree.
-
In the text, I demonstrated how to use inorder traversal to print a list ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access