Professional Documents
Culture Documents
Binary Trees
Binary Trees
1
, ,
. , , , ,
.
, .
, (
), , , , . ,
.
, .. ,
.
, .
() .
, .
.
, .
, , ,
, .
, , ,
(.. , ) ,
. .
.
.
.
2
, ().
: , , , .
. ,
, , , . ,
, ,
.
( ).
5
. 1:
. , ,
. ,
.
? ,
O(log N ) (
) , , O(log N )
( O(N )). ,
O(N ) ,
O(log N ) O(log N ).
, , .
. 2:
if (root != NULL) {
print_tree(root->left);
printf("%d ", root->key);
print_tree(root->right);
}
O(N ).
, , x y
, .
O(H), .. .
, , ,
N H .
, ( ), H
O(log N ) . ,
, , random_shuffle STL,
.
,
.