You are on page 1of 5

( 3.7 .


// n, table //
i 2 n
j n i _ 1
table[j - 1] > table[j]
temp

table[j - 1]

table[j - 1] table[j]
table[j]

temp

_
_
_
// table //

:
-

- . ,
- table ( -
3.3.2.6)





i,

. ,
"" "" ""
.

, :

16

11

4 . :
i=2
j=5 j=4 j=3 j=2

16

16

11

16

16

11

11

11

, . :
i=3
j=5 j=4 j=3
1

16

16

16

11

11

11

, . :
i=4
j=5 j=4

11

11

16

16

i=5
j=5
1
3
8
11
16
:


. ,
. ,
,
_
// n, table //
i

_
_

j n i _ 1
table[j - 1] > table[j]

table[j - 1]
table[j - 1] table[j]
table[j] temp
_

temp

_
_
i

i+1

_ (i > n) (_ = )
// table //
_

3.3 2 . :

_2
// n, table //
_
_

i 1 n-1
table[i + 1] < table[i]

table[i + 1]
table[i + 1] table[i]
table[i] temp
_

temp

_
_
_ (_ = )
// table //
_2

( 4.2.1 )

T__
// n, table //
i 1 n
j

k i + 1 n
table[k] < table[j]
j

_
_

table[j]
table[j] table[i]
table[i] temp
temp

_
// table //
T__


,
.
. ,
. , 5
, 52. .

( 3 , 3)

"" .
T___
// table, n //
i 2 n
temp

table[i]

i-1
done
j

done =
j = 0 ! ,
done

_ temp < table[j]


table[j + 1]
j

j-1

done

table[j]

! ,

_
_
table[j + 1]

temp

_
// table //
T___

:
. 2 (
). .
:

You might also like