现在的位置: 首页 > 综合 > 正文

堆和栈 Heap and Stack

2013年08月20日 ⁄ 综合 ⁄ 共 521字 ⁄ 字号 评论关闭

堆是基于二叉树的数据结构,有两种类型的堆:大堆和小堆。

大堆是指对于每个节点,其值要大于等于左右子树中节点的值;

小堆是指对于每个节点,其值要小于等于左右子树中节点的值。

栈是一种后进先出(Last In First Out)/先进后出(First In Last Out)的线性数据结构,其插入和删除操作均在某一端进行,该端称之为顶(Top)。栈可以用来检查语法错误,例如括号不匹配。

 

Heap

A heap is a binary tree-based data structure. There are two types of heap: maximum heap and minimum heap. In maximum heap, for every node, its value is greater than or equal to that of its sub-trees.

Stack

A Stack is a LIFO linear structure in which insertions and deletions are always made at one end, called the top. It is useful when we need to check some syntax errors, such as missing parentheses.

 

抱歉!评论已关闭.