swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Followup about binary trees


From: Paul E. Johnson
Subject: Re: Followup about binary trees
Date: Wed, 02 Dec 1998 12:45:33 -0600

"Marcus G. Daniels" wrote:
> 
> >>>>> "PJ" == Paul E Johnson <address@hidden> writes:
> 
> PJ> Why does a delete function need
> PJ> to know the compare_function?  The compare_function has one detail
> PJ> in it that works great when adding nodes but it causes a lot of
> PJ> trouble when it comes time to delete nodes.
> 
> To delete a node, it first must be found, and a comparison function
> is needed to do that.  Perhaps you could use a second compare function?
> 
Yes, I've already got that code working. I just put the function inside
the method where it is called, so it is localized (correct?). That means
I have one compare_nodes in one method, a slightly different one in the
other, all works ok.

But I still don't understand it or your comment.  Can you put some more
words down for me?   Apparently, a node is considered found when it is
compared against itself, and 0 is returned?  What would happen if my
comparison function were written so it never returned 0. Say it returned
1 if >= and -1 if <.   According to what one person wrote to me about
trees, that would be acceptable as far as tree-creating is concerned. 
But would that mean tdelete would never delete anything?

-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.edu/~pauljohn
University of Kansas                    Office: (785) 864-9086
Lawrence, Kansas 66045                  FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]