3 ms·
Imagine you've got ten pieces you need to stick end to end a b c d e f g h i j How many ways can you do that with a binary operation? i.e. how many ways
by tome 11y ago
Imagine you've got ten pieces you need to stick end to end
a b c d e f g h i j
How many ways can you do that with a binary operation? i.e. how many ways can you completely parenthesise that expression. e.g.
((a (((b (c d)) e) ((f g) h)) i) j)
I haven't worked it out exactly, but I think it's about a trillion.
On the other hand, suppose your binary operation is associative. How many different ways are there now? Effectively one.
That's a huge reduction in complexity. The notion of associativity is extremely useful in developing composable programs.
- radicality 11y agoAre you sure of that? Isn't the answer to your question the Catalan numbers, for which this case the answer is 4862?
- tome 11y agoI'm not sure at all! My calculation came out very wrong, and a quick sanity check should have told me it's implausible that it's in the trillions. Anyway, 4862 times is still a substantial complexity reduction. Thanks for the correction.