Skip to content

Commit b575613

Browse files
committed
Update heap.h
1 parent 2fb4c5a commit b575613

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

include/heap.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77
*
88
* Heap Data structure
99
*
10-
* Heaps can be used as an array. For any key at array position I,
11-
* left child is at ( 2i ), right child is at ( 2i+1 ) and parent is
12-
* at (int) (i / 2). Heap size is stored at index 0.
10+
* In computer science, a heap is a specialized tree-based data structure that
11+
* satisfies the heap property: If A is a parent node of B then the key of node
12+
* A is ordered with respect to the key of node B with the same ordering applying
13+
* across the heap. Heaps can be classified further as either a "max heap" or
14+
* a "min heap". In a max heap, the keys of parent nodes are always greater
15+
* than or equal to those of the children and the highest key is in the root node.
16+
* In a min heap, the keys of parent nodes are less than or equal to those of
17+
* the children and the lowest key is in the root node. Heaps are crucial in
18+
* several efficient graph algorithms such as Dijkstra's algorithm, and in
19+
* the sorting algorithm heapsort. A common implementation of a heap is the
20+
* binary heap, in which the tree is a complete binary tree (see figure).
1321
*
1422
* Basic operations of a heap are:
1523
*
16-
* 1. Insert – Insert an key.
17-
* 2. Delete minimum – Delete and return the smallest item in the heap.
24+
* 1. Push – Insert an key.
25+
* 2. Pop – Delete and return the smallest item in the heap.
26+
* 3. Remove - Remove an element
1827
*
1928
* http://en.wikipedia.org/wiki/Binary_heap
2029
******************************************************************************/

0 commit comments

Comments
 (0)