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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

j = 1<br />

[ End of if statement ]<br />

[ End of step 4 loop ]<br />

7. [ Copy the child record into its proper place ]<br />

A [i] = key<br />

[ End of step 1 for loop ]<br />

8. [ Finished ]<br />

Return<br />

Algorithm : Heap_Sort ( A,N )<br />

<strong>1.</strong> [ Create the initial heap ]<br />

Call Create_Heap (A,N)<br />

2. [ Perform the sort ]<br />

Repeat step 3 to 10 for Count = N to i‐1<br />

3. [ Exchange the first element with the last unsorted element ]<br />

A [i] = A [Count]<br />

4. [ Initialise Pass]<br />

i = 1<br />

key = A[i]<br />

j = 2<br />

5. [ Obtain index of largest son ]<br />

if j+1 < Count then<br />

if A[j+1] > A[j] then<br />

j = j +1<br />

[ End of inner if statement]<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!