From 390333bb314f6cb25adc5716ea383112860ed342 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 8 Aug 2020 13:01:36 +0100 Subject: add parallelquick and so on --- sort/insertion.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sort/insertion.go') 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 } -- cgit v1.2.3