mirror of
https://gitlab.com/magicalsoup/Highschool.git
synced 2025-02-02 21:01:46 -05:00
Update Shellsort List.md
This commit is contained in:
parent
2c0612b30e
commit
3e06aaa403
@ -1,6 +1,7 @@
|
||||
# Shell Sort Handout
|
||||
|
||||
## What is shell sort?
|
||||
- "Diminishing Increment Sort", better known as comb sort
|
||||
- Combination of sorting by insertion (insertion sort) and sorting by exchange (bubble sort)
|
||||
- Starts off by comparing two elements that are far apart and gradually reduce the gap between them
|
||||
- It works better than regular insertion sort as it moves certain out of place elements into place faster
|
||||
@ -44,4 +45,12 @@ public static void shellSort(int arr[]) // Method Header
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
## Enhanced Shell Sort
|
||||
- A method to calculate the gap sequence and can decrease the number of comparisons by up to 60%
|
||||
- Published by Basit Shahzad and Muhammad Tanvir Afzal from the World Academy of Science
|
||||
- The gap sequence would be h<sub>1</sub> and h<sub>n+1</sub> = 3h<sub>n</sub>+1
|
||||
- For 100 elements, shell's original gap seuqence will make 170 comparisons but the Enhanced Shell Sort will make 85 comparisons
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user