在按所示顺序将元素71、65、84、69、67、83插入空的二进制搜索树(BST)中时,最低级别的元素为
null
(A) 65 (B) 67 (C) 69 (D) 83 答复: (B) 说明: 以下是二进制搜索树的插入算法:
Insert(Root,key) { if(Root is NULL) Create a Node with value as key and return Else if(Root.key >= key) Insert(Root.left,key) Else Insert(Root.right,key) }
在下图中使用上述算法逐个创建BST:
这个解决方案是由 Pranjul Ahuja。 这个问题的小测验
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END