Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _...

27
1 Radix sort Counting sort Overview of sorts asymptotic complexities Sorting experiment ALG 09 A4B33ALG 2011 / 09

Transcript of Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _...

Page 1: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

1

Radix sort

Counting sort

Overview of sorts asymptotic complexities

Sorting experiment

ALG 09

A4B33ALG 2011 / 09

Page 2: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

2

DaD

DbD

DCaaDb

aDDCCC

aDCDDb

babbbC

aCb

Cbb

Cba

5

109

1

6

2

7

3

8

4

1211

13

B_ _ a _ _ b _ _ C _ _ D

Cbb DaDaDb

DCa CCCaDD

DDbaDCbbC

babDbD

Cba1 23

4 56

789

1011

12

aCb13

12

567

34

1098

1211

13

Unsorted Sort by the 3rd symbol

Radix sort

New order 1Previous order 1

A4B33ALG 2011 / 09

Page 3: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

3

5

109

1

6

2

7

3

8

4

1211

13

B_ a _ _ b _ _ C _ _ D_Cbb

DaD

aDb

DCa

CCC

aDD

DDb

aDCbbC

bab

DbD

Cba

aCb

12

56

734

10

98

1211

13

Sorted from3rd symbol

DCaCbaCbb

aDbDDb

babaCbCCC aDCbbC

DaD

aDDDbD

123

45

678 910

11

1213

Sort by the 2nd symbol

Radix sortA4B33ALG 2011 / 09

Page 4: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

4

5

109

1

6

2

7

3

8

4

1211

13

Ba _ _ b _ _ C _ _ D_ _

12

56

7

34

10

98

1211

13DCa

CbaCbb

aDbDDb

bab

aCbCCC

aDC

bbC

DaD

aDD

DbDbab DaDCba

CbbbbC DbDDCa

aCb

CCCaDb

DDbaDCaDD

1 2345 6

7

8

910

111213

Sorted!Sorted!

Sorted form 2nd symbol Sort by the 1st symbol

Radix sortA4B33ALG 2011 / 09

Page 5: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

5

Example

DaD

DbD

DCaaDb

aDDCCC

aDCDDb

babbbC

aCb

Cbb

Cba

5

109

1

6

2

7

3

8

4

1211

13

B_ _ a

_ _ b

_ _ C

_ _ D

DaD

aDb

DCa

CCC

aDD

DDb

aDCbbC

bab

DbD

Cba

13

4

5

7

89

10

12

aCb13

12

567

34

1098

1211

13

Unsorted Sorted by the 3rd symbol

2611

start & end next

abC

6

Cbb

4152

1213911

123456789

10111213

D

712811109013000

33

Example

Radix sort ImplementationAuxiliary index arrays

register modified order

A4B33ALG 2011 / 09

Page 6: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

6

DaD

DbD

DCaaDb

aDDCCC

aDCDDb

babbbC

aCb

Cbb

Cba

5

109

1

6

2

7

3

8

4

1211

13

Unsorted

Radix sort Implementation

367

128111090

13000

abC

4 12

D

1 135 92 11

Example:The listin the

"b" slot

One array for all lists

Array of pointersto the start and tothe end of the listfor each symbol

Radix sort can be performedwithout moving the original data.

It suffices just to manipulate thepointer arrays which containall information about thecurrent progress of the sort.

Here, both arrays reflect the statusafter sorting by

the 3rd character.s e

A4B33ALG 2011 / 09

Page 7: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

7

DaD

DbD

DCaaDb

aDDCCC

aDCDDb

babbbC

aCb

Cbb

Cba

5

109

1

6

2

7

3

8

4

1211

13

Unsorted

907

130086112015

abC

10 2

D

12 114 53 6

Example:The listin the

"b" slot

Radix sort Implementation

51187000609413

abC

13 6

D

10 912 52 7

After: sortedby the 2nd symbol

After: sorted by the 1st symbol = all sorted

s e s e

A4B33ALG 2011 / 09

Page 8: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

8

51187000609413

13 610 912 52 7

abCD

DaD

DbD

DCaaDb

aDDCCC

aDCDDb

babbbC

aCb

Cbb

Cba

5

109

1

6

2

7

3

8

4

1211

13

Unsorted

Radix sort Implementation

After: sorted by the 1st symbol = all sorted

Just print the data in theorder given by the lists: a b C D

aCbaDbaDCaDDbabbbCCbaCbbCCCDaDDbDDCaDDb

13386109121521147

s e

A4B33ALG 2011 / 09

Page 9: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

9

Cbb

5

109

1

6

2

7

3

8

4

1211

13

907

130086112015

abC

10 2

D

12 114 53 6

From sorted by 2nd symbol to sorted by 1st symbol

s e

DaDaDbDCaCCCaDDDDbaDCbbCbabDbDCbaaCb

d

0000000000000

abC

0 0

D

0 00 00 0

s1s1 e1e1

d1d1

1

2

5

6

7

3

4

10

9

8

121113

Update arrays s, e, d:Fill temporary arrrays

s1, e1, d1and copy their contents

back to s, e, d.

Implementation will notcopy anything, it will

only swap the pointersto the original andtemporary arrays.

Arrays will specifyorder after

sorted by the1st symbol.

Arrays specify

order after sorted by the2nd symbol.

A4B33ALG 2011 / 09

Page 10: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

10

Cbb

5

109

1

6

2

7

3

8

4

1211

13

907

130086112015

abC

10 2

D

12 114 53 6

s e

DaDaDbDCaCCCaDDDDbaDCbbCbabDbDCbaaCb

d

0000000000000

abC

0 0

D

0 00 00 0

s1s1 e1e1

d1d1

0000000000000

0 010 100 00 0

s1s1 e1e1

d1d1

0000000000000

0 010 100 02 2

s1s1 e1e1

d1d1

0000000000000

0 010 1012 122 2

s1s1 e1e1

0000000000010

0 010 1012 12 2

s1s1 e1e1

0000000009010

0 010 912 12 2

s1s1 e1e1

01100000009010

0 010 912 12 11

s1s1 e1e1

d1d1 d1d1 d1d1 d1d1

1

2

5

6

7

3

4

10

9

8

121113

Sortedby the

2ndsymbol

From sorted by 2nd symbol to sorted by 1st symbolA4B33ALG 2011 / 09

Page 11: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

11

Cbb

5

109

1

6

2

7

3

8

4

1211

13

907

130086112015

abC

10 2

D

12 114 53 6

DaDaDbDCaCCCaDDDDbaDCbbCbabDbDCbaaCb

d

abCD

01100000009410

0 010 912 12 4

d1d1

01100000009410

13 1310 912 12 4

d1d1

51100000009410

13 1310 912 52 4

d1d1

51100000009413

13 310 912 52 4

d1d1

51107000009413

13 310 912 52 7

d1d1

51180000009413

13 810 912 52 7

d1d1

51180000609413

13 610 912 52 7

d1d1

1

2

5

6

7

3

4

10

9

8

121113

From sorted by 2nd symbol to sorted by 1st symbol

FinishedFinished

A4B33ALG 2011 / 09

Sortedby the

2ndsymbol

s e s1s1 e1e1 s1s1 e1e1 s1s1 e1e1 s1s1 e1e1 s1s1 e1e1 s1s1 e1e1 s1s1 e1e1

Page 12: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

12

Radix sort Implementation

def radixSort(A):alphabetsize = 128 # 2^16 in unicodeS = [0] * alphabetsize # all startsE = [0] * alphabetsize # all endsD = [0] * len(A) # all listsS1 = [0] * alphabetsize E1 = [0] * alphabetsizeD1 = [0] * len(A)

radixInit(A, S ,E, D) # 1st pass with last char

for p in range(len(A[0])-2, -1, -1):radixStep(A, p, S, E, D, S1, E1, D1)S, S1 = S1, S # just swap arraysE, E1 = E1, E # dittoD, D1 = D1, D # ditto

radixOutput(A, S, E, D) # print sorted A

A4B33ALG 2011 / 09

Page 13: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

13

Radix sort Implementation

def radixInit(A, S, E, D):pos = len(A[0]) - 1 # last char in stringfor i in range(len(S)):

S[i], E[i] = -1, -1 for i in range(len(A)):

c = ord(A[i][pos]) # char to indexif S[c] == -1:

S[c], E[c] = i, i # start new listelse: # extend existing list

D[E[c]] = iE[c] = i

Add trailing spaces to shorter strings to make all stringsof the same length.

Caution: The arrays in the code are indexed from 0,The arrays in the code are indexed from 1.

A4B33ALG 2011 / 09

Page 14: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

14

Radix sort Implementation

def radixStep(A, pos, S, E, D, S1, E1, D1):for i in range(len(S)):

S1[i], E1[i] = -1, -1 # init arrays

for i in range(len(S)):if S[i] != -1: # unempty old list

j = S[i] # traverse the listwhile True:

c = ord(A[j][pos]) # list indexif S1[c] == -1:

S1[c], E1[c] = j, j # start new listelse: # extend existing list

D1[E1[c]] = jE1[c] = j

if j == E[i]:break

j = D[j] # next string index

A4B33ALG 2011 / 09

Page 15: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

15

d symbols ............ d loops

loop ............

d << n ..….

(n) operations

Asymptotic complexity of Radix sort is (d·n)

Resume

(d·n) operationstotal ............

(n) operations

Radix sort does not change the order of equal values.

It is a stable sort.

Radix sortA4B33ALG 2011 / 09

Page 16: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

16

2 0 4 02 0 1 3

563 8 810 8 10 6 10 83

5 63 3 6 8 8 8 8 10 10 10

3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10 11 12

1 2 3 4 5 6 7 8 9 10 11 12

Frequencyfrequency.length == k

Inputinput.length == N

k = max(input) - min(input) + 1

Outputoutput.length == N

Counting sortA4B33ALG 2011 / 09

Page 17: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

17

Step 1

Fill the frequency array

563 8 810 8 10 6 10 83

2 0 4 02 0 1 3

3 4 5 6 7 8 9 10

0 0 0 00 0 0 0

3 4 5 6 7 8 9 10

One pass through the input array

Reset frequency array

Counting sortA4B33ALG 2011 / 09

for x in inputArr:freq[x] += 1

Page 18: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

18

Step 2

33 44 55 66 77 88 99 10102 0 1 2 0 4 0 3

for i in range(low+1, high+1):freq[i] += freq[i-1]

One pass

Update the frequncy array

Elem freq[ j ] denotes position of the last elem with value jin the output array

1 2 3 4 5 6 7 8 9 10 11 12 5 63 3 6 8 8 8 8 10 10 10

33 44 55 66 77 88 99 10102 2 3 5 5 9 9 12

Frequency array changes its

meaning

Counting sortA4B33ALG 2011 / 09

low = 3 high = 10

Page 19: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

19

Step 3

1 2 3 4 5 6 7 8 9 10 11 12 5

33 44 55 66 77 88 99 10102 2 3 5 5 9 9 12

for i in range(N, 0, -1):output[freq[input[i]]] = input[i]freq[input[i]] -= 1

i == N

33 44 55 66 77 88 99 10102 2 2 5 5 9 9 12

563 8 810 8 10 6 10 831 2 3 4 5 6 7 8 9 10 11 12 i == 12

Counting sortA4B33ALG 2011 / 09

Page 20: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

20

1 2 3 4 5 6 7 8 9 10 11 12 5

33 44 55 66 77 88 99 10102 2 2 5 5 9 9 12

33 44 55 66 77 88 99 10102 2 2 5 5 8 9 12

563 8 810 8 10 6 10 831 2 3 4 5 6 7 8 9 10 11 12 i == 11

8

Step 3

i == N-1

Counting sortA4B33ALG 2011 / 09

for i in range(N, 0, -1):output[freq[input[i]]] = input[i]freq[input[i]] -= 1

Page 21: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

21

1 2 3 4 5 6 7 8 9 10 11 12 5

33 44 55 66 77 88 99 10102 2 2 5 5 8 9 12

33 44 55 66 77 88 99 10102 2 2 5 5 8 9 11

563 8 810 8 10 6 10 831 2 3 4 5 6 7 8 9 10 11 12 i == 10

8 10

Step 3

i == N-2

etc...

Counting sortA4B33ALG 2011 / 09

for i in range(N, 0, -1):output[freq[input[i]]] = input[i]freq[input[i]] -= 1

Page 22: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

22

1 2 3 4 5 6 7 8 9 10 11 12 5

33 44 55 66 77 88 99 10101 2 2 3 5 6 9 10

33 44 55 66 77 88 99 10101 2 2 4 5 5 9 10

563 8 810 8 10 6 10 831 2 3 4 5 6 7 8 9 10 11 12 i == 3

8 103 6 8 8 8 106

Step 3

i == 3

etc...

Counting sortA4B33ALG 2011 / 09

for i in range(N, 0, -1):output[freq[input[i]]] = input[i]freq[input[i]] -= 1

Page 23: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

23

Selection sort

Insertion sort

Bubble sort *)

Quick sort

Merge sort

Heap sort

Radix sort

Counting sort

Worst case Best caseAverage,

"expected"case

(n2) (n2) (n2)

(n2) (n2)(n)

(n2) (n2) (n2)

(n2) (nlog(n))

(nlog(n)) O(nlog(n)) (nlog(n))

(nlog(n)) (nlog(n)) (nlog(n))

(n) (n) (n)

(n) (n) (n)

Array size n

Sorts complexities overview

(nlog(n))

No

No **)

No

Yes

Yes

Yes

Yes

Yes

Stable

**) Stable slow versions exist*) Not recommended to use

A4B33ALG 2011 / 09

Page 24: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

24

Small sorting experiment

Conclusion

There is no particular sort method which would be optimal in all circumstances.

The performance is influenced by the data size and by the degree of the original organisation (partial order) of the data.

Environment

Intel(R) 1.8 GHz, Microsoft Windows XP SP3, jdk 1.6.0_16.

Organization

Explored the sorts which compare the elements value (double). Each datasets of particular datasizes used in all sorts.

Arrays values generated by the pseudorandom generator.The results are the averages of repeated runs.

A4B33ALG 2011 / 09

Page 25: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

25

Select Insert QuickBubble Merge HeapSort

0.00040.0005

0.028

2.36

228

22 900

38 min

0.00010.0002

0.016

1.30

130

12 800

22 min

0.00040.0005

0.043

4.45

450

45 000

75 min

0.00040.0004

0.081

0.12

1.57

18.7

237

0.00070.0009

0.014

0.19

2.40

31.4

385

0.00050.0005

0.011

0.17

2.31

31.4

570

0.026 0.003 0.030 0.010 0.011 0.011

2.31 0.18 2.86 0.16 0.15 0.16

229 17.5 285 1.93 1.68 2.11

38 min 2.9 min 47.5 min 336 301 381

22 900 1 760 28 500 27.4 24.6 25.5

0%90%

1 000 0001 000 000

100 000100 000

10 00010 000

1 0001 000

1010

100100 0%

90%0%90%0%90%0%90%0%90%

Array size%

sorted

Small sorting experiment

Time in milliseconds if not indicated otherwise

Degree of order. 100% –x% of sorted data are randomly chosenand their values are randomly changed.

A4B33ALG 2011 / 09

Page 26: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

26

Select Insert QuickBubble Merge HeapSort

11.3

3.4

20

146

1 220

9 960

0.260.7

1.8

11

83

686

5 400

0.961.4

5.4

37.5

287

2 410

19 000

11

1

1

1

1

1

1.82.5

1.75

1.65

1.53

1.7

1.6

1.31.4

1.35

1.4

1.48

1.7

2.41

2.46 0.28 2.9 1 1.07 1.07

15 1.2 18.5 1 0.95 1.03

118 9.1 148 1 0.87 1.09

6 820 521 8 480 1 0.9 1.14

837 64.1 1 040 1 0.9 0.93

Slowest StableSelection and Bubble sort do not compete.

0%90%

1 000 0001 000 000

100 000100 000

10 00010 000

1 0001 000

1010

100100 0%

90%0%90%0%90%0%90%0%90%

Array size % sorted

Small sorting experiment

Fastest

Ratio of slowdown ( >1 ) compared to Quick sort

A4B33ALG 2011 / 09

Page 27: Radix sort Counting sort Overview of sorts asymptotic ... · 3 5 10 9 1 6 2 7 3 8 4 12 11 13 Cbb _ a _B _ b _ _ C _ _ D_ DaD aDb DCa CCC aDD DDb aDC bbC bab DbD Cba aCb 1 2 5 6 3

27

0%90%

Select Insert QuickBubble Merge Heap

1 000 0001 000 000

100 000100 000

10 00010 000

1 0001 000

1010

100100

Sort

0%90%0%90%0%90%0%90%0%90%

0.81

0.91

0.981

1.01

1.01

1.01

0.51

0.21

0.141

0.141

0.141

0.141

0.81

0.681

0.641

0.631

0.631

0.631

11

1.271

1.311

1.231

1.461

1.421

0.81

0.781

0.751

0.71

0.781

0.781

11

11

0.951

0.911

0.811

0.671

Array size % sorted

Small sorting experiment

Ratio of slowdown ( > 1) when comparingthe sort speeds

of unsorted and partially sorted data.

Stable

A4B33ALG 2011 / 09