Skip to content

Instantly share code, notes, and snippets.

@shehaaz
Created December 16, 2013 00:52
Show Gist options
  • Save shehaaz/7980742 to your computer and use it in GitHub Desktop.
Save shehaaz/7980742 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