|
Introduction
Syllabus
Guidelines for labs
Lab sections
Take quiz & check grades
| |
Heap (Chapter 7)
is an array:
 | that can be viewed as a complete binary tree |
 | tree is filled in all levels except, possibly, the last |
 | last level, if not filled is filled from the left |
properties:
 | lenght ... number of elements in the array |
 | heapsize ... number of elements in the heap stored in the array (heapsize <=lenght) |
if elements are numbered from 1 to n:
 | root of the tree is A[1] |
 | Parent(i) = i/2; |
 | Left(i)=2*i; ... left child of node i |
 | Right(i)=2*i+1; right child of node i |
Heap property:
For every node i, except for the root: A[Parent(i)]>=A[i];
|