0% found this document useful (0 votes)
23 views

Metode Sorting: Selection Sort: Algorimta

The document describes the selection sort algorithm. It works by iterating through the list and finding the minimum element, swapping it with the first unsorted element. It repeats this process for the remaining unsorted elements, building the sorted list from left to right at each iteration. The example shows each step of applying selection sort to a sample list of numbers.

Uploaded by

Joss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Metode Sorting: Selection Sort: Algorimta

The document describes the selection sort algorithm. It works by iterating through the list and finding the minimum element, swapping it with the first unsorted element. It repeats this process for the remaining unsorted elements, building the sorted list from left to right at each iteration. The example shows each step of applying selection sort to a sample list of numbers.

Uploaded by

Joss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Metode Sorting : Selection Sort

Algorimta :
Int Data[10], N;
int i, j, t;
for(i=1; i<N; i++)
{
for(j=i+1; j<N; j++)
{
if(Data[j] < Data[i])
{
t = Data[i];
Data[i] = Data[j];
Data[j] = t;
}
}
}

Table Algoritma : Metode Sorting : Selection Sort

Data[ j ]

Data
1
30

Data
2
10

Data
3
25

Data
4
50

Data
5
65

Data
6
45

Data
7
60

Data
8
100

Data
9
75

Data
10
95

30

30

10

25

50

65

45

60

100

75

95

30

10

30

25

50

65

45

60

100

75

95

1
1
1
1
1
1
1
1

30
30
30
30
30
30
30
30

10
10
10
10
10
10
10
10

30
30
30
30
30
30
30
30

25
25
25
25
25
25
25
25

50
50
50
50
50
50
50
50

65
65
65
65
65
65
65
65

45
45
45
45
45
45
45
45

60
60
60
60
60
60
60
60

100
100
100
100
100
100
100
100

75
75
75
75
75
75
75
75

95
95
95
95
95
95
95
95

30

10

30

25

50

65

45

60

100

75

95

3
25
25
4
25
5
25
6
25
7
25
8
25
9
25
10
Interasi Ketiga
30
4
30
5
30
6
30
7
30
8
30
9
30
10
Interasi Keempat
50
5
50
6

30

10

25

30

50

65

45

60

100

75

95

2
2
2
2
2
2
2

30
30
30
30
30
30
30

10
10
10
10
10
10
10

25
25
25
25
25
25
25

30
30
30
30
30
30
30

50
50
50
50
50
50
50

65
65
65
65
65
65
65

45
45
45
45
45
45
45

60
60
60
60
60
60
60

100
100
100
100
100
100
100

75
75
75
75
75
75
75

95
95
95
95
95
95
95

3
3
3
3
3
3
3

10
10
10
10
10
10
10

25
25
25
25
25
25
25

30
30
30
30
30
30
30

50
50
50
50
50
50
50

65
65
65
65
65
65
65

45
45
45
45
45
45
45

60
60
60
60
60
60
60

100
100
100
100
100
100
100

75
75
75
75
75
75
75

95
95
95
95
95
95
95

4
4

50

10
10

25
25

30
30

50
50

65
65

45
45

60
60

100
100

75
75

95
95

6
45
45
7
45
8
45
9
45
10
Interasi Kelima
65
6

50

10

25

30

45

65

50

60

100

75

95

4
4
4
4

50
50
50
50

10
10
10
10

25
25
25
25

30
30
30
30

45
45
45
45

65
65
65
65

50
50
50
50

60
60
60
60

100
100
100
100

75
75
75
75

95
95
95
95

65

10

25

30

45

65

50

60

100

75

95

6
50
50
7
50
8
50
9
50
10
Interasi Keenam
65
7

65

10

25

30

45

50

65

60

100

75

95

5
5
5
5

65
65
65
65

10
10
10
10

25
25
25
25

30
30
30
30

45
45
45
45

50
50
50
50

65
65
65
65

60
60
60
60

100
100
100
100

75
75
75
75

95
95
95
95

65

10

25

30

45

50

65

60

100

75

95

65

10

25

30

45

50

60

65

100

75

95

6
6
6

65
65
65

10
10
10

25
25
25

30
30
30

45
45
45

50
50
50

60
60
60

65
65
65

100
100
100

75
75
75

95
95
95

10
10
10

25
25
25

30
30
30

45
45
45

50
50
50

60
60
60

65
65
65

100
100
100

75
75
75

95
95
95

Data[ I ]

Data Awal
Interasi Pertama
10

30

Pertukaran
30
25
50
65
45
60
100
75
95
25

2
10
10
3
10
4
10
5
10
6
10
7
10
8
10
9
10
10
Interasi Kedua
30
3

Pertukaran
30
50
65
45
60
100
75
95
50
65
45
60
100
75
95
65
45
Pertukaran
50
60
100
75
95
50
Pertukaran
65
60
100
75
95
60
Pertukaran

7
60
60
8
60
9
60
10
Interasi Ketujuh
100
65
8
75
65
9
95
65
10
Interasi Kedelapan
75
100
9
Pertukaran
9
100
75
95
75
10
Interasi Kesembilan
95
100
10
Pertukaran
10
100
95
65
100
75
95

Data Akhir

7
7
7
8

100

10

25

30

45

50

60

65

100

75

95

100

10

25

30

45

50

60

65

75

100

95

100

10

25

30

45

50

60

65

75

100

95

100

10

25

30

45

50

60

65

75

100

95

100

10

25

30

45

50

60

65

75

95

100

10

25

30

45

50

60

65

75

95

100

You might also like