Red Black Tree implementation?

duncan smith buzzard at invalid.invalid
Sun May 12 14:15:13 EDT 2013


On 12/05/13 03:02, duncan smith wrote:
> On 12/05/13 02:29, Dan Stromberg wrote:
>>
>> On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg <drsalists at gmail.com
>> <mailto:drsalists at gmail.com>> wrote:

[snip]

>>
>> What should BinaryTree.find() do if it finds a data.node that is None?
>>
>
> A call to "find(data)" should find and return either a node containing
> "data"; or the sentinel node where "data" should be added. It should not
> get as far as the left or right child of a sentinel node (which would
> equal None). I'll look at this tomorrow. I did have the truth value of a
> node depending on it's data value (None implying False). Then I
> considered the possibility of actually wanting None as a value in the
> tree and changed it, so I could have introduced a bug here.
>

It's a Python3 thing. The initial sentinel node was evaluating to True. 
__nonzero__ needs to be changed to __bool__.

>> Thanks!
>>
>> PS: Is it about time we moved this discussion off python-list?
>>

Let's do that from now.

Duncan




More information about the Python-list mailing list