4 ms·
Ah, that's a much more direct interpretation. I'd always considered the /2 to mean find the middle element. take the biggest and the smallest, add them, and mul
by jfoutz 9y ago
Ah, that's a much more direct interpretation. I'd always considered the /2 to mean find the middle element. take the biggest and the smallest, add them, and multiply by the middle. Which is a little closer to my drawing. My interpretation is bad, because i'd always have to mentally special case odd length sequences.
Your way, the doubling is obvious, so you see why you can always /2 at the end.
Hmm. Haven't thought about this stuff in years. This was a pretty pleasing thing to revisit.
- zellyn 9y agoSee, my obnoxious questions are awesome :-p Actually, I came here to post the correction rodorgas beat me to posting. But your diagram works too: 1/2 base * height… nice.