堆VS二叉搜索树(BST) [英] Heap vs Binary Search Tree (BST)
本文介绍了堆VS二叉搜索树(BST)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
堆和BST之间的区别是什么?
What is the difference between a heap and BST?
在使用堆以及何时使用BST?
When to use a heap and when to use a BST?
如果你想在一个列表中的元素,是BST好了堆?
If you want to get the elements in a sorted fashion, is BST better over heap?
推荐答案
堆只是保证在较高的水平元素更高(最大堆)或小(最小堆),比上下级元素,而BST保障顺序(从左到右)。如果要排序的元素,去与BST。
Heap just guarantees that elements on higher levels are greater (for max-heap) or smaller (for min-heap) than elements on lower levels, whereas BST guarantees order (from "left" to "right"). If you want sorted elements, go with BST.
这篇关于堆VS二叉搜索树(BST)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文