Paul Rubin <http://[email protected]> writes:
> Example comparison function:
>
> def compare(tree1, tree2):
> c = cmp(tree1['value'], tree2['value'])
> if c != 0: return c
> c = cmp(tree1['left'], tree2['left'])
> if c != 0: return c
> return cmp(tree1['right'], tree2['right])
Sorry, meant recursive comparison.
def compare(tree1, tree2):
c = cmp(tree1['value'], tree2['value'])
if c != 0: return c
c = compare(tree1['left'], tree2['left'])
if c != 0: return c
return compare(tree1['right'], tree2['right])
--
http://mail.python.org/mailman/listinfo/python-list