Skip to content

Instantly share code, notes, and snippets.

@shehaaz
Last active December 31, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shehaaz/7980715 to your computer and use it in GitHub Desktop.
Save shehaaz/7980715 to your computer and use it in GitHub Desktop.
let rec trace_insert ((x,d) as e) t = match t with
| Empty -> (Node(e,Empty,Empty), H x)
| Node((y,d'),l,r) -> if (y=x) then (Node(e,l,r),H x)
else if x<y then
let(t',tr) = trace_insert e l in ( Node((y,d'),t',r), L(y,tr) )
else
let(t',tr) = trace_insert e r in ( Node((y,d'),l,t'), R(y,tr) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment