I have made a binary search tree from this sequence: 4, 1, 7, 5, 6, 3, 0, 2, 9, 8
And I just want to make sure that it is correct. Starting with 4. Then 1 which is less than 4 so its placed on the left side. 7 is greater than 4 so it becomes the right child of 4. 5 is less than 7 so it becomes the left child of 7. 6 is greater than 5 so it becomes the right child of 5. 3 is greater than 1 so it becomes the right child of 1. 0 is less than 1 so it becomes the left child of 1. 2 is less than 3 so it becomes the left child of 2. 9 is greater than 7 so it becomes the right child of 7. And finally 8 which is less than 9 so it becomes left child of 9. Is this correct?
Asked
Active
Viewed 22 times
2
Peter
- 67
- 2
-
6Looks good to me! – 5xum Oct 12 '22 at 08:50
-
1The result and the description of the process you wrote all are fine, showing you understood binary search tree. So it would be interesting to know about which point you still have a doubt ? – zwim Oct 12 '22 at 10:01
