Anda di halaman 1dari 16

SORTING ALGORITHMS : BUBBLE DOWN SORT

Position

1 2 3 4 5 6 7 8 9 10

7 5 1 9 3 11

5 1 7 3 9 11

1 5 3 7 9 11

1 3 5 7 9 11

1 3 5 7 9 11

Comparisons Exchanges

5 3

4 2

3 1

286 7

version 3

Fast

286

Slow

Ascending Descending Totals

14 6

SORTING ALGORITHMS : INTERCHANGE SORT


Position

1 2 3 4 5 6 7 8 9 10

7 5 1 9 3 11

1 5 7 9 3 11

1 3 7 9 5 11

1 3 5 9 7 11

1 3 5 7 9 11

1 3 5 7 9 11

Comparisons Exchanges

5 1

4 1

3 1

2 1

289 7 4

version 3

Fast

289

Slow

Ascending Descending Totals

15 4

SORTING ALGORITHMS : QUICK SORT


Position

1 2 3 4 5 6 7 8 9 10

15 13 12 11 10 9 7 6 5 3

13 12 11 10 9 7 6 5 3 15
9

12 11 10 9 7 6 5 3 13

11 10 9 7 6 5 3 12

10 9 7 6 5 3 11

9 7 6 5 3 10

7 6 5 3 9

6 5 3 7

5 3 6

Comparisons

624 7

10

Now the pivot nu placing everything everything smalle This pivot numb place so it can be Notice how the o changed You now have pivot number. Repeat the proc the list on each su

version 3

3 5 6 7 9 10 11 12 13 15
Total

Fast

624

Slow

Ascending Descending

The quick sort algorithm is based on a number and sub-lists. Now the pivot number is made permanent by way of obtaining a pivot number ca The placing everything bigger than it below and For this course we are going to use the fi everything smaller on top. number in the list as pivot number. This pivot number is definitely in the correct place so it can be fixed. Notice how the order of other numbers has not changed. You now have two sub-lists either side of the pivot number. Repeat the process of picking a pivot and sorting the list on each sub-list.
1 45

sort algorithm is based on a pivot

of obtaining a pivot number can vary. urse we are going to use the first he list as pivot number.

SORTING ALGORITHMS : SHUTTLE SORT


Position

1 2 3 4 5 6 7 8 9 10

20 30 Ahmad Zainal 30 20 30 Ahmad Ahmad Ahmad 20 30 Zainal Zainal Zainal 20

Comparisons Exchanges

1 1

2 2

3 3

10 7

version 3

Fast

Slow

Ascending Descending Totals

6 6

SORTING ALGORITHMS : Data


Copy and paste data for using in sorting algorithms
Position

1 2 3 4 5 6 7 8 9 10

44 51 55 25 34 8 21 17 15 8

7 5 2 4 10 1 6 3

7 5 1 9 3 11

1 2 3 4 5 6 7

7 6 5 4 3 2 1

Val Russ Phil Claire Bob David Liam Larisa Andy

13 56 2 40 10 50 35

81 92 76 43 82 45 51 93 71 62

Syed Ibrahim Nazri Zubir Azwan Bob Azman Aimi

19 7

10

version 3

9 5 7 6 11 15 10 12 3 13

SORTING ALGORITHMS : INSERTION SORT


Pos

1 2 3 4 5 6 7 8 9 10

7 5 2 4 10 1 6 3

Comparisons

620 7 19

version 3

Fast

620

Slow

Ascending Descending Total

SORTING ALGORITHMS : BUBBLE UP SORT


Position

1 2 3 4 5 6 7 8 9 10

5 2 9 6 8

Comparisons Exchanges

151 7

version 3

Fast

Slow

Ascending Descending Totals

0 0

Character ASCII code 1 17 2 18 3 19 4 20 5 21 6 22 7 23 8 24 9 25 10 26 11 27 12 28 13 29 14 30 15 31 16 32

! " # $ % & ' ( ) * + , . / 0

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

1 2 3 4 5 6 7 8 9 : ; < = > ? @

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

A B C D E F G H I J K L M N O P

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

Q R S T U V W X Y Z [ \ ] ^ _ `

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

a b c d e f g h i j k l m n o p

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

q r s t u v w x y z { | } ~

113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

Anda mungkin juga menyukai