10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

property and a heap that satisfies this property is known as maximum<br />

heap.<br />

If the order property is such that for every node in the heap, the value stored in<br />

that node is less than or equal to the value in each of its children, then that<br />

heap is known as minimum heap.<br />

STEPS IN HEAP SORT<br />

Heap sort follows two main steps:‐<br />

Step I:‐ creation of heap<br />

Step II:‐ operation on heap<br />

CREATION OF HEAP<br />

A heap is a complete binary tree in which every node satisfies the heap<br />

condition.<br />

HEAP CONDITION<br />

A complete binary tree is said to satisfy the heap condition if the key of each<br />

node is greater than or equal to the key in its children.<br />

Thus the root node will have the largest key value<br />

OPERATION ON HEAP<br />

The steps of operations are as follows:‐<br />

Step I – Remove the root node of the heap and insert it into the sorted list from<br />

right to left.<br />

Step II‐ Replace the deleted element (root) by the last element.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 17 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!