Shell sort

of 11

Please download to get full document.

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
PDF
11 pages
0 downs
13 views
Share
Description
1. 1 2. 2 Name Nauman Ali Class BS CS 3 ReG # 024 Indroduction 3. 3 PROJECT NAME 4. 4 Shell Sort – Basic idea generalization of insertion sort  Create a gap by half…
Transcript
  • 1. 1
  • 2. 2 Name Nauman Ali Class BS CS 3 ReG # 024 Indroduction
  • 3. 3 PROJECT NAME
  • 4. 4 Shell Sort – Basic idea generalization of insertion sort  Create a gap by half the number of array. Compare the elements and sort. Repeat sorting until gap become equal to 1. For gap Donald Knuth.. Start with h = 1 h = 3*h + 1 h > n h = (h – 1) / 3
  • 5. 5 Shell Sort - example 8 2 5 34 67 1 Total numbers of element 8. Initialy Gap = 4 7 1 3 54 68 2
  • 6. 6 Shell Sort - example (2) 7 2 5 34 68 1 Gap =4/ 2 Gap=2 3 1 5 82 67 4
  • 7. 7 Shell Sort - example (3) 1 2 3 74 85 6 3 1 5 82 67 4 Gap = 2/2 Gap=1
  • 8. 8
  • 9. 9 Shell sorting code for( gap=n/2; gap>0; gap/=2) { for( i= gap; i<n; i++ ) { temp=array[i]; for(j=i; j>=gap && array[j-gap]>temp ; j - = gap) { array[j]=array[j-gap]; } array[j]=temp; } } N=8 Gap = 4
  • 10. 10 references Youtube and en.wikipedia.org/wiki/Shellsort
  • 11. 11
  • Related Search
    We Need Your Support
    Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

    Thanks to everyone for your continued support.

    No, Thanks