Artikel Struktur Data

Sorting array x = [18,3,9,8,28,2] n=6

x i j Besar indeks

18,3,9,8,28,2 5 1 18 0

2 – –
3 – –

4 28 4

5 – –

6 – –

18,3,9,8,2,28 4 1 18 0

2 – –

3 – –

4 – –

5 – –

2,3,9,8,18,28 3 1 2 0

– 3 1

2 9 2

3 – –

4

2,3,8,9,18,28 2 1 2 0

– 3 1

2 8 2

3

2,3,8,9,18,28 1 1 2 0

– 3 1

2

2,3,8,9,18,28 0

Algoritma : selection sort
void select short (int x ,int n)
{ int I , indeks , besar , j ;
for ( I = n-1 ; i > 0 , i – – )
{ besar = x [0] ;
Indeks = 0 ;
for ( j = 1 ; j , besar)
{ besar = x [ j ]
Indeks = j
}
X [ indeks ] = x [ i ]
X [ i ] = besar
} // end for
} // end select short

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: