Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.36 KB | None | 0 0
  1.  
  2. type 'a bt = Empty | Node of 'a * 'a bt * 'a bt;;
  3.  
  4. let tt = Node(1,Node(2,Node(4,Empty,Empty),Empty),Node(3,Node(5,Empty,Node(6,Empty,Empty)),Empty));;
  5.  
  6. let internalPath tree=
  7.     let rec helper Node(value,tl,tr) depth=
  8.         match Node with
  9.         | Empty -> 0
  10.         | Node(_,tl,tr) -> depth + helper(depth+1) tl + helper(depth+1) tr
  11.         in helper 0 tree;;
  12. internalPath tt;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement