STRUKTUR DATA DAN ALGORITMA
Soal :
1.
Urutkan 10 bilangan
berikut dengan insertion sort dan selection sort
Insertion sort
INDEX
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
awal
|
5
|
20
|
3
|
16
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 2
|
5
|
20
|
3
|
16
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 3
|
3
|
5
|
20
|
16
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 4
|
3
|
5
|
16
|
20
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 5
|
3
|
5
|
16
|
20
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 6
|
3
|
5
|
8
|
16
|
20
|
21
|
25
|
4
|
50
|
28
|
i = 7
|
3
|
5
|
8
|
16
|
20
|
21
|
25
|
4
|
50
|
28
|
i = 8
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
50
|
28
|
i = 9
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
50
|
28
|
i = 10
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
28
|
50
|
Selection sort
INDEX
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
awal
|
5
|
20
|
3
|
16
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 0
|
3
|
20
|
5
|
16
|
21
|
8
|
25
|
4
|
50
|
28
|
i = 1
|
3
|
4
|
5
|
16
|
21
|
8
|
25
|
20
|
50
|
28
|
i = 2
|
3
|
4
|
5
|
16
|
21
|
8
|
25
|
20
|
50
|
28
|
i = 3
|
3
|
4
|
5
|
8
|
21
|
16
|
25
|
20
|
50
|
28
|
i = 4
|
3
|
4
|
5
|
8
|
16
|
21
|
25
|
20
|
50
|
28
|
i = 5
|
3
|
4
|
5
|
8
|
16
|
20
|
25
|
21
|
50
|
28
|
i = 6
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
50
|
28
|
i = 7
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
50
|
28
|
i = 8
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
28
|
50
|
akhir
|
3
|
4
|
5
|
8
|
16
|
20
|
21
|
25
|
28
|
50
|
Tidak ada komentar:
Posting Komentar