Live data from Hacker News

Inverting a binary tree using x64 assembly

sanket.tech

71–73 of 73 posts

Re: Inverting a binary tree using x64 assembly

#71
post #60
post #22

Earlier quoted context omitted.

For those who don't know, that's why big and little endian were called that, because the debate was so frivolous. It's a reference to the book Gulliver's Travels by Jonathan Swift in which an island folk was split about from which end you should crack a boiled egg. (I'm a big endian for example).

Genuinely curious, what are any advantages of big endian other than "it's how we write numbers in base 10?"

Sorting (assuming your numbers are unsigned and same width, you can sort them as byte strings).

Dispatch (if only the topmost n-bits (or bytes) are needed to make a decision, that's all you need to read).

Re: Inverting a binary tree using x64 assembly

#72
post #49

Earlier quoted context omitted.

Is there a practical reason to do this in a real-world program?

Sure, it’s the binary tree equivalent of reversing an array.

For large enough trees it's probably more efficient to instead just switch from preorder to postorder traversal instead of changing the whole tree.
Post reply on HN