3 ms·
You mean, "regurgitate" operations like this? find = lambda k, t: t if t is None or k == t.k else find(k, t.left) if k < t.k else find(k, t.right) I mean,
by kragen 5y ago
You mean, "regurgitate" operations like this?
find = lambda k, t: t if t is None or k == t.k else find(k, t.left) if k < t.k else find(k, t.right)
I mean, figuring out how to rebalance a red-black tree after insertion is more demanding, and you could legitimately quibble with my golfing here, but I feel like the reasoning required to write that function (given the tree definition) is just not that advanced. It's like the FizzBuzz of pointers.