Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. struct tree {
  2. int data;
  3. tree* left;
  4. tree* right;
  5. };
  6.  
  7. int find_min(tree* root, int min_elem) {
  8. if (root != NULL) {
  9. if (root->data <= min_elem) {
  10. min_elem = root->data;
  11. }
  12. int min1 = find_min(root->left, min_elem);
  13. int min2 = find_min(root->right, min_elem);
  14. if (min1 < min2) {
  15. return min1;
  16. }
  17. else {
  18. return min2;
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement