Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. let rec btree_size t = match t with
  2. |Empty->0
  3. |Node(_, g, d)->1+(btree_size g)+(btree_size d);;
  4.  
  5. let rec btree_height t = match t with
  6.  
  7. |Empty-> -1
  8. |Node(n,g,d) -> 1 + max (btree_height g) (btree_height d);;
  9.  
  10.  
  11. let rec btree_mem x t = match t with
  12. |Empty->false
  13. |Node(a,g,d)->if a=x then true else btree_mem x g || btree_mem x d ;;
  14.  
  15. let rec arity t = match t with
  16. |Empty-> -1
  17. |Node(_,Empty,Empty)-> 0
  18. |Node(_,a,Empty)-> 1
  19. |Node(_,Empty,b)-> 1
  20. |Node(_,a,b)-> 2;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement