On 10 May 2008, at 00:35, PR Stanley wrote:

Hi
data Ord a => Tree a = Nil | Node (Tree a) a (Tree a)
How would one go about inserting a value in a binary search tree of the above description?

All you need to do is consider what the trees should look like in the two cases:

If I try and insert an item into a completely empty tree, what do I end up with? I'll give you a hint, it has one Node, and 2 Nils. If I have a Node, do I need to insert into the left tree, or the right tree?

Take it from there

Bob
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to