   deleting from a ternary tree
  Hi all,I've been trying for quite some time to make a function to remove a string from a ternary tree. I've been using ternary trees for quite some time, but now I wish I could delete stuff from them.I can't find a proper way to do that. Can anyone shed some light on how I would do this, short of copying the tree?Thanks!--Eric   
  Can you please post (at least) your data structure?You just need a simple recursive function either taking a reference to a node, or returning a node which is assigned to the original parent. Then you simply make a few recursive calls on the children, and don't forget to check for NULL being passed in as the first thing you do. Oh, and of course you unallocate and remove the nodes you don't want anymore.What part are you having trouble with?   ;type tree = Node of (tree*tree*tree)*string | Leaflet rec remove (tree) (string) =   match tree with  | Node (left,center,right),value ->  let left = remove (left) (string) and center = remove (center) (string) and right = remove (right) (string) in if string = value then    subtree(subtree (center) (left))(right) else (Node (left,center,right),value)  | Leaf -> Leafand subtree (tree) (inserted) =   match tree with  | Node (left,center,right),value ->  let center = subtree (center) (inserted)  in (Node (left,center,right),value)  | Leaf -> inserted;  Woah Victor!I don't know what language the code you posted is in, but I am both impressed and completely baffled by it. I've used a lot of languages in my time, but this one I know nothing about.--Eric;  This language is Objective Caml, of the ML family. Functional languages are very well adapted to tree manipulation, even more so when they include pattern matching like O'Caml does.   ;  Proof that no matter how much you think you know, in the end you usually don't :)Thanks for answering anyway.--Eric