Hi developers,
I only wanne know: Is this solution right?
Problem:
I have to write a function wich returns
the largest key (node->key == Max) in an ordered binary tree.
int Maxkey(const node*)
I must do it on brute force (so easiest ) way.
Given:
Code:
Struct node {
Int key;
Struct node *left, *right;
}
I have developted the code. Can someone look at it if it's right(good).
My sollution:
Code:
int Maxkey( const node *n) {
int max=o;
if (n == NULL)
return;
else while (n->right != NULL) {
if (max > n->key)
max = n->key;
n->right;
}
return max;
}
Is this code ok??
Thanx people
Holland