Last active
          August 29, 2015 14:04 
        
      - 
      
 - 
        
Save mgiacomini/387af420f68793b136ff to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | typedef struct node { | |
| int key; | |
| struct node *left; | |
| struct node *right; | |
| } node; | |
| int is_odd(node *n){ | |
| // verify the root key | |
| if (n->key % 2 != 0) | |
| return 1; | |
| return 0; | |
| } | |
| int find_path_with_max_odd_keys(node *root){ | |
| int keys, left_keys, right_keys = 0; | |
| if(is_odd(root) == 1) | |
| keys++; | |
| left_keys = find_path_with_max_odd_keys(root->left); | |
| right_keys = find_path_with_max_odd_keys(root->right); | |
| if(left_keys >= right_keys) | |
| return keys + left_keys; | |
| return keys + right_keys; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment