开发者

Is a Binary Search Tree inherited upward or inherited downward?

开发者 https://www.devze.com 2023-03-15 13:03 出处:网络
And why? I tried googling but it wouldn\'t come up with any answers. I know that if the two nodes of the root are binary search trees, then the top one is a binary search tree. But does this mean tha

And why? I tried googling but it wouldn't come up with any answers.

I know that if the two nodes of the root are binary search trees, then the top one is a binary search tree. But does this mean that开发者_开发问答 it is inherited upward or inherited downward?

Thanks :)


If you were writing a function to check if a tree is a BST, then you would start at the top node, and recursively go down the child nodes checking if each one is a BST tree as well. On the other hand, you can also start at the bottom and work your way up inductively. Both solutions are ideal.

0

精彩评论

暂无评论...
验证码 换一张
取 消