declare an integer MAX and assign any negative number to the variable MAX , for example MAX=-1

traverse the given binary tree by using any of the (Preorder,Postorder,Inorder,Level order) available traversing techniques, if weight of any node is greater then MAX , assign weight of that node to MAX. here is the Preorder travesrsal function that returns Max as maximum weight of binary tree

```
int preorderTraversal(root){
if(root){
if(MAX<root->weight)
MAX=root->weight;
preorderTraversal(root->left);
preoderTraversal(root->right);
}
return MAX;
}
```