Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "arbol.h"
- int rango(TNode *node,int min,int max){
- if (node==NULL)
- return 1;
- if (node->elem>max || node->elem<min)
- return 0;
- return rango(node->left,min,max) && rango(node->right,min,max);
- }
- int main(){
- TBinaryTree T;
- init_tree(&T);
- insert(&T, 12);
- insert(&T, 7);
- insert(&T, 16);
- insert(&T, 15);
- insert(&T, 1);
- insert(&T, 2);
- insert(&T, 6);
- insert(&T, 8);
- insert(&T, 29);
- printf("%d\n",rango(T.root,1,28));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment