SE250:lab-6:shua066

From Marks Wiki
Jump to navigation Jump to search

Lab6

Task 1

the relationship between the size and the height is

size	height
1	1
2	2
3	3
4	4
5	5
6	5
7	5
8	6
9	6
10	6
20	9
30	10
40	10
60	11
100	13

code

int main(){
    int a=60;
    printf(" the height is %d ", height(makeRandomTree(a)));
}

Task 2

code

Node* minimum( Node* node ) {
  /* TODO */
    if( node ==  empty)
	return ;
    while (node != empty){
        node = node->left;
	return node;
    }
}

Node* maximum( Node* node ) {
  /* TODO */
    if (node == empty)
	return ;
    while (node != empty){
	node= node->right;
	return node;
    }
}
 printf("the min node is %d\n ", minimum(makeRandomTree(a)));
 printf("the max node is %d ", maximum(makeRandomTree(a)));

result

 the min node is 17041240
 the max node is 17042680

the number is very big