need help ASAP ,

• 05-14-2007
Haytham
need help ASAP ,
well ,,
here is a function i search for the Max GPA in a tree , where :
Code:

```struct treenode {       int st_id;       float gpa;       ptrtotree left;       ptrtotree right; }; void MaxGPA(ptrtotree t,float max)        //here : float &max ?!!! {     if(t!=NULL)     {                 if(t->gpa > max)                 {                               max=t->gpa;                 }                 MaxGPA(t->left,max);                 MaxGPA(t->right,max);     } } // i am wondering how can i define the float max , or float *max , void main {     float max;```

need help ASAP
• 05-14-2007
ZuK
Code:

`void MaxGPA(ptrtotree t,float max)        //here : float &max ?!!!`
This is c. It has to be
Code:

```void MaxGPA(ptrtotree t,float * max) {     if(t!=NULL)     {                 if(t->gpa > * max)                 {                               *max=t->gpa;                 }                 MaxGPA(t->left,max);                 MaxGPA(t->right,max);     } }```
Kurt
• 05-14-2007
brewbuck
Is this a binary tree? As in, a tree where the left nodes are all less than the right nodes? Can you see the pointlessness of scanning the entire tree? Just find the rightmost child. By definition it will be the greatest.
• 05-14-2007
ssharish2005
Ya, he could have put a if statment in main before calling MaxGPA function. Becuase, head node->gpa coule be < max or > max. If it is < then cleck only the left handside of the tree other wise the right handside of the tree.

ssharish2005