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 />

ALGORITHM FOR INSERTON SORT<br />

Insertion_sort(A,N)<br />

Here A is a linear array having N no. of elements<br />

1: Repeat step 2 to 4 for I=2 to N<br />

2: Set temp =A[I]<br />

Position=I‐1<br />

3: [Move down 1 position all elements greater than temp]<br />

Repeat while temp=1<br />

(i) Set A[position+1]=A[position]<br />

(ii)Set position=position‐1<br />

[end of loop]<br />

4: Insert temp at proper position<br />

Set A[position+1]=temp<br />

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

5: Finished<br />

Exit<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!