August 2024
Intermediate to advanced
516 pages
11h 47m
English
As I mentioned earlier, binary search trees are at their best when it comes to insertion. Now we’ll see why.
Say we want to insert the number 45 into our example tree. The first thing we’d have to do is find the correct node to attach the 45 to. To begin our search, we start at the root, as shown in the following illustration:

Since 45 is less than 50, we drill down to the left child:

Since 45 is greater than 25, we must inspect the right child:
Since 45 is greater than 33, we check the 33’s right child:
At this point, we’ve reached a ...
Read now
Unlock full access