University of California, Santa Cruz

Prof. Paulo Franca - Spring 2000

Introduction

Syllabus

Guidelines for labs

Lab sections

Take quiz & check grades

Heap   (Chapter 7)

is an array:

bulletthat can be viewed as a complete binary tree
bullettree is filled in all levels except, possibly, the last
bulletlast level, if not filled is filled from the left

properties:

bulletlenght ... number of elements in the array
bulletheapsize ... number of elements in the heap stored in the array (heapsize <=lenght)

if elements are numbered from 1 to n:

bulletroot of the tree is A[1]
bulletParent(i) = i/2;
bulletLeft(i)=2*i;   ... left child of node i
bulletRight(i)=2*i+1; right child of node i

Heap property:

For every node i, except for the root: A[Parent(i)]>=A[i];