diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2020-08-08 13:01:36 +0100 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2020-08-08 13:01:36 +0100 |
| commit | 390333bb314f6cb25adc5716ea383112860ed342 (patch) | |
| tree | 2b87d5741d84b2cd2d7c74eaaa0f522c3a8a221c /sort/insertion.go | |
| parent | deaa4e1c33cd2c1c75f698881918688055abfa51 (diff) | |
add parallelquick and so on
Diffstat (limited to 'sort/insertion.go')
| -rw-r--r-- | sort/insertion.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sort/insertion.go b/sort/insertion.go index 3e271b0..983edf2 100644 --- a/sort/insertion.go +++ b/sort/insertion.go @@ -5,9 +5,12 @@ import ( ) func Insertion(a ds.ArrayList) ds.ArrayList { - length := len(a) + insertion(a, 0, len(a)-1) + return a +} - for i := 0; i < length; i++ { +func insertion(a ds.ArrayList, lo, hi int) { + for i := lo; i <= hi; i++ { for j := i; j > 0; j-- { if a[j].Higher(a[j-1]) { break @@ -15,6 +18,4 @@ func Insertion(a ds.ArrayList) ds.ArrayList { a.Swap(j, j-1) } } - - return a } |
