.


:




:

































 

 

 

 


()




, , (, ) , . , .

. (l, r) l r, . (l, r), l=1, r=n, . m=(l+r) div 2. Key>A[m], ( ), Key , m+l r, , l=m+1, . r=m. . .

. l r, , .

:

l:= 1; r:= n;while (l<>r) dobegin m:= (l+r) div 2; if Key>A[m] then l:= m+1 else r:= m;end;if A[l]=Key then < > else < >;

, , T(log(n)).

. ( , , ). .

, , , . , :

i:= n;while (i>=1)and(A[i]>Key) dobegin A[i+1]:= A[i]; {} Dec(i);end;A[i+1]:= Key;Inc(n);

T(n).

, 2.1. .

, . , , . , . .

(l, r). , , . ( )

( )

.

l:= 1; r:= n;while (l<>r) dobegin m:= l+(r-l)*(Key-A[l])/(A[r]-A[l]); if Key>A[m] then l:= m+1 else r:= m;end;if A[l]=Key then < > else < >;

, , . . , - . , . T(log(log(n))). , , , , n. n .

, . : .

.

:

1. .

2.

3. .

4.

 

?

?

2 , ?.

3

(, , ).

 

 

: . , , .

 

6 .

 

 

(, );

, .

;

.

 

 

.

, , (64 ), (16 ) . , , 200-300 .

- , , .

, .

Turbo Pascal . , . , .

, 64 , 16 (.. 0, 16, 32,64 ..). , , .

, , . .

 

 

, , . , . , .

. , , . , . , (- ), , .

, ( ) () ( ).

 

:

() , , :

 

Type

Element =...;

Link = ^Node;

Node = record

Data: Element;

Next: Link;

Prev: Link;

end;

 

Element : , , , , .. Node , Link . . Data Next Prev. , , . Next, ().

, () . .

 

Type

List = Link;

Var

List1, List2: List;

 

(). :

 

Type

List = record

Head: Link; { }

Tail: Link; { }

end;

. Next, , nil.

, . , -, , , -, . , .. . , ( ). .

, . , , . .





:


: 2017-02-25; !; : 351 |


:

:

, - , ; , - .
==> ...

1454 - | 1464 -


© 2015-2024 lektsii.org - -

: 0.017 .