Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct node{
- int key,
- struct node* left,
- struct node* right,
- } *Node
- typedefstruct nodet{
- int key,
- int diff,
- struct nodet* left,
- struct nodet* right,
- } *NodeT
- NodeT funzionechiamante(node T)
- {
- NodeT T1 = malloc(sizeof(NodeT));
- funzionericorsiva(T,T1);
- return T1;
- }
- int funzionericorsiva(node T, nodet T1)
- {
- T1.key = T.key;
- T1.left = null;
- T1.right = null;
- T1.diff = 0;
- int diff = 0;
- if (T.left != null)
- {
- T1.left = malloc(sizeof(NodeT));
- diff =abs(diff- funzionericorsiva(T.left,T1.left));
- }
- if (T.right != null)
- {
- T1.right = malloc(sizeof(NodeT));
- diff =abs(diff- funzionericorsiva(T.right,T1.right));
- }
- T1.diff=diff;
- return diff;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement