[Haskell-cafe] inserting values in a binary tree
PR Stanley
prstanley at ntlworld.com
Fri May 9 19:10:59 EDT 2008
>Are there any invariants you wish to maintain when inserting? If
>not, it's rather trivial.
Paul: The idea is to find a value in the tree greater than
the new value and then placing the new value before it on the tree.
duplicates are ignored and if no value greater than he new value is
found then it is appended as a new node to the end of the last node checked.
in C you'd fiddle with pointers and Bob's your uncle. Here I'm not
sure how to piece that tree back together again with the new element
after having expanded it recursively.
Cheers
Paul
More information about the Haskell-Cafe
mailing list