mercredi 23 septembre 2020

Binary Search Tree insert C#

So I have a binary search tree in which numbers are being inserted in this order: 3-0-10-14-8. Is this the correct bst?

binary search tree drawing

Because I have the following test that needs to be successful, yet it gives me a System.NullReferenceException.

test line

Just to be sure I'd like to know if I'm correct with my first question in this post, because it doesn't sound logical to me that 'big_tree.root.left.right.right.number' is supposed to be eight. If I look at it, it's supposed to be 'big_tree.root.right.left.number'. So I think there's something I'm missing and not understanding. Thank you in advance. If more information is required, please ask.

Aucun commentaire:

Enregistrer un commentaire